我正在尝试使用“文件浏览器”对话框选择文件,并在文本框中显示路径
例如“ C:\ Program Files”
这是我的代码示例:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles bwrBtn.Click
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
rootTxt.Clear()
Dim grade As New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath)
Dim inFiles As IO.FileInfo() = grade.GetFiles()
Dim fLinfo As IO.FileInfo
For Each fLinfo In inFiles
rootTxt.Text(fLinfo)
Next
End If
'Exit File Directory
End Sub
用户选择文件时,文件目录应出现在文本框中
答案 0 :(得分:2)
我不是VB开发人员,但可能类似这样的事情:
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
rootTxt.Clear()
Dim grade As New IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath)
Dim inFiles As IO.FileInfo() = grade.GetFiles()
Dim fLinfo As IO.FileInfo
Dim directoryPath As string = Path.GetDirectoryName(FolderBrowserDialog1.SelectedPath)
rootTxt.Text = directoryPath
End If