我正在尝试使用FolderBrowserDialog (在VBExpress2013中)来允许用户选择工作目录。我发现了许多示例(都非常相似),但事情似乎不起作用。
我的代码:
Sub TestIt()
Dim dlgChooseFolder As New FolderBrowserDialog
Dim dr As DialogResult
dlgchoosefolder.Description = _
"Select the directory that you want to use As the default."
' Default to the My Documents folder.
dlgChooseFolder.RootFolder = Environment.SpecialFolder.Personal
'dlgChooseFolder.SelectedPath = "c:\users\mary\Documents\WebStuff"
dr = dlgChooseFolder.ShowDialog
If (dr = DialogResult.OK) Then
Debug.Print("dr = OK" & vbCrLf & dlgChooseFolder.SelectedPath)
Else
Debug.Print("dr <> OK")
End If
End Sub 将显示对话框,但树中唯一的条目是"Documents",并且它不会展开以显示其子目录。即使我在ShowDialog之前显式设置了SelectedPath属性,它也总是重置为RootFolder。
下面是显示的对话框:FolderBrowserDialog
有人能帮上忙吗?我做错了什么?
谢谢,
梅布尔
发布于 2017-06-16 12:27:11
我95%确定这是Windows10的问题。我已经将.RootFolder设置为Environment.SpecialFolder枚举的所有59个成员。它们中的一些显示目录树,而许多则不显示。既不是MyDocuments,也不是个人工作。对于我的目的来说,最有效的值是MyComputer。另一种选择似乎是“滚你自己的”。
https://stackoverflow.com/questions/44559311
复制相似问题