.NET Select USB 驱动器作为默认的 FolderBrowserDialog 路径
.NET Select USB drive as default FolderBrowserDialog path
各位编程大师大家好,
当前路径(文件夹)是通过点击按钮选择的。
Private Sub SelectButton_Click(sender As Object, e As EventArgs) Handles SelectButton.Click
FolderBrowserDialog1.ShowDialog()
Path.Text = FolderBrowserDialog1.SelectedPath
End Sub
有什么方法可以将U盘路径设为默认FolderBrowserDialog.SelectedPath?
谢谢!
试试下面的代码:
Dim folder = New FolderBrowserDialog()
Dim drives = System.IO.DriveInfo.GetDrives()
Dim usbDrive = drives.FirstOrDefault(Function(m) m.DriveType = System.IO.DriveType.Removable)
folder.SelectedPath = usbDrive.RootDirectory.FullName
If folder.ShowDialog() = DialogResult.OK Then
MessageBox.Show(folder.SelectedPath)
End If
各位编程大师大家好,
当前路径(文件夹)是通过点击按钮选择的。
Private Sub SelectButton_Click(sender As Object, e As EventArgs) Handles SelectButton.Click
FolderBrowserDialog1.ShowDialog()
Path.Text = FolderBrowserDialog1.SelectedPath
End Sub
有什么方法可以将U盘路径设为默认FolderBrowserDialog.SelectedPath?
谢谢!
试试下面的代码:
Dim folder = New FolderBrowserDialog()
Dim drives = System.IO.DriveInfo.GetDrives()
Dim usbDrive = drives.FirstOrDefault(Function(m) m.DriveType = System.IO.DriveType.Removable)
folder.SelectedPath = usbDrive.RootDirectory.FullName
If folder.ShowDialog() = DialogResult.OK Then
MessageBox.Show(folder.SelectedPath)
End If