RootFolder排序作品當與SelectedPath
Using fbd As New FolderBrowserDialog
fbd.RootFolder = Environment.SpecialFolder.MyComputer
fbd.SelectedPath = "H:\temp\scans"
If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
MsgBox(fbd.SelectedPath)
End If
End Using
這至少顯示所需的文件夾相結合 - 所有其它路徑仍然可用,如果用戶向上滾動。
這是我發現使用標準的OpenFileDialog在網上搜索最接近:
Using obj As New OpenFileDialog
obj.Filter = "foldersOnly|*.none"
obj.CheckFileExists = False
obj.CheckPathExists = False
obj.InitialDirectory = "C:\temp"
obj.CustomPlaces.Add("H:\OIS") ' add custom location
obj.CustomPlaces.Add("H:\Permits") ' add custom location
obj.Title = "Select folder - click Open to return opened folder name"
obj.FileName = "OpenFldrPath"
If obj.ShowDialog = Windows.Forms.DialogResult.OK Then
MsgBox(IO.Directory.GetParent(obj.FileName).FullName)
End If
End Using
編輯CustomPlaces.Add()爲您的環境 - 這些文件夾顯示在右上方的導航面板。
`obj.FileName =「OpenFldrPath」」是有問題 - 在什麼可以例如被用來限制一個短語失敗。
注意到關於開放兩次點擊返回文件路徑。
使用'System.IO.Directory.GetFiles()'和'一個ListBox'? – dummy
您可以通過讓用戶命名集合來隱藏用戶的所有實現細節。然後當他們選擇一個名字時 - 你的代碼爲它們加載相關的集合。不需要**他們**來記住「set01」的含義或者他們存儲的位置。 – Plutonix