Answers for "vb.net open file with default program"

C#
1

vb.net open file with default program

Dim OpenFileDlg as new OpenFileDialog.

OpenFileDlg.FileName = "" ' Default file name
OpenFileDlg.DefaultExt = ".xlsx" ' Default file extension
OpenFileDlg.Filter = "Excel Documents (*.XLSX)|*.XLSX"
OpenFileDlg.Multiselect = True
OpenFileDlg.RestoreDirectory = True
' Show open file dialog box
Dim result? As Boolean = OpenFileDlg.ShowDialog()

' Process open file dialog box results
for each path in OpenFileDlg.Filenames
    Try
        System.Diagnostics.Process.Start(Path)

    Catch ex As Exception
        MsgBox("Unable to load the file. Maybe it was deleted?")
    End Try
    If result = True Then
        ' Open document
    Else
        Exit Sub
    End If
next
Posted by: Guest on April-12-2021

C# Answers by Framework

Browse Popular Code Answers by Language