您应该像这样使用OpenFileDialog类
Dim fd As OpenFileDialog = New OpenFileDialog() Dim strFileName As String fd.Title = "Open File Dialog" fd.InitialDirectory = "C:\" fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" fd.FilterIndex = 2 fd.RestoreDirectory = True If fd.ShowDialog() = DialogResult.OK Then strFileName = fd.FileName End If
然后,您可以使用File类。