mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 23:43:07 +02:00
Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Diagnostics
|
||||
Imports System.IO
|
||||
Imports System.Security
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Public Class OpenFileDialogForm : Inherits Form
|
||||
Dim WithEvents selectButton As Button
|
||||
Dim openFileDialog1 As OpenFileDialog
|
||||
|
||||
Public Shared Sub Main()
|
||||
Application.SetCompatibleTextRenderingDefault(false)
|
||||
Application.EnableVisualStyles()
|
||||
Dim frm As New OpenFileDialogForm()
|
||||
Application.Run(frm)
|
||||
End Sub
|
||||
|
||||
Private Sub New()
|
||||
openFileDialog1 = New OpenFileDialog() With
|
||||
{
|
||||
.FileName = "Select a text file",
|
||||
.Filter = "Text files (*.txt)|*.txt",
|
||||
.Title = "Open text file"
|
||||
}
|
||||
|
||||
selectButton = New Button() With {.Text = "Select file"}
|
||||
Controls.Add(selectButton)
|
||||
End Sub
|
||||
|
||||
Public Sub selectButton_Click(sender As Object, e As EventArgs) _
|
||||
Handles selectButton.Click
|
||||
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
||||
Try
|
||||
Dim filePath = OpenFileDialog1.FileName
|
||||
Using str = openFileDialog1.OpenFile()
|
||||
Process.Start("notepad.exe", filePath)
|
||||
End Using
|
||||
Catch SecEx As SecurityException
|
||||
MessageBox.Show($"Security error:{vbCrLf}{vbCrLf}{SecEx.Message}{vbCrLf}{vbCrLf}" &
|
||||
$"Details:{vbCrLf}{vbCrLf}{SecEx.StackTrace}")
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user