我有以下代码:
Imports System.IO
Public Class Form2
Dim fileName As String = "C:\Users\Sam\Desktop\Visual Basic\Test\test.txt"
Dim pathname As String = "C:\Users\Sam\Desktop\Visual Basic\Test\test.txt"
Dim result As String
Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
fdTxtFile.InitialDirectory = "C:\Users\Sam\Desktop\Visual Basic\Test"
fdTxtFile.ShowDialog()
' fdTxtFile.
End Sub
Private Sub fdTxtFile_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles fdTxtFile.FileOk
Dim strm As System.IO.Stream
result = Path.GetFullPath(fdTxtFile.ToString)
tbFileLocation.Text = result
strm = fdTxtFile.OpenFile()
' tbFileLocation.Text =
End Sub
End Class
但是,当使用 Path.GetFullPath() 时,它会打开文件对话框,我选择文件,然后 ok 按钮什么也不做,没有错误。我正在尝试获取它,以便它将所选文件的完整文件路径显示到文本框,但是这让我很烦。其他函数,如 GetFileName() 等,点击 OK 后没有任何作用。