📜  vb.net 使用默认程序打开文件 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:52.449000             🧑  作者: Mango

代码示例1
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