如何使用WindowsAPICodePack在OpenFileDialog中指定电脑的特定位置?

2026-05-06 12:311阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计304个文字,预计阅读时间需要2分钟。

如何使用WindowsAPICodePack在OpenFileDialog中指定电脑的特定位置?

我想将WindowsAPICodePack和CommonOpenFileDialog的InitialDirectory属性设置为我的计算机位置,我使用的是有效的CLSID或GUID,或者到底是什么,我只是想知道是否存在更原生/更安全的方式来正确设置我的目录。

我想将 WindowsAPICodePack CommonOpenFileDialog的InitialDirectory属性设置为我的计算机位置,我是使用等效的CLSID或GUID做的,或者到底是什么,只是我想知道是否存在更原生/安全的方式来正确设置我的电脑位置,我试过这个,但没有奏效:

.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer)

这是我正在使用的代码:

Dim FolderPicker As New Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog With FolderPicker .IsFolderPicker = True .Title = "Folder Dialog Test" .InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ' My Computer .DefaultFileName = "C:\" End With

UPDATE:

我在Windows 8 x64上.

如何使用WindowsAPICodePack在OpenFileDialog中指定电脑的特定位置?

其他特殊文件夹(如库和桌面)的工作方式如下:

.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) Environment.GetFolderPath永远不会返回MyComputer的路径,因为它实际上没有路径.

从MSDN documentation:

The MyComputer constant always yields the empty string (“”) because no
path is defined for the My Computer folder.

这意味着您的解决方案是最好的(并且可能是没有太多人知道​​的解决方案).为了将来的兴趣,here is a link到可用的CLSID列表.

本文共计304个文字,预计阅读时间需要2分钟。

如何使用WindowsAPICodePack在OpenFileDialog中指定电脑的特定位置?

我想将WindowsAPICodePack和CommonOpenFileDialog的InitialDirectory属性设置为我的计算机位置,我使用的是有效的CLSID或GUID,或者到底是什么,我只是想知道是否存在更原生/更安全的方式来正确设置我的目录。

我想将 WindowsAPICodePack CommonOpenFileDialog的InitialDirectory属性设置为我的计算机位置,我是使用等效的CLSID或GUID做的,或者到底是什么,只是我想知道是否存在更原生/安全的方式来正确设置我的电脑位置,我试过这个,但没有奏效:

.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer)

这是我正在使用的代码:

Dim FolderPicker As New Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog With FolderPicker .IsFolderPicker = True .Title = "Folder Dialog Test" .InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ' My Computer .DefaultFileName = "C:\" End With

UPDATE:

我在Windows 8 x64上.

如何使用WindowsAPICodePack在OpenFileDialog中指定电脑的特定位置?

其他特殊文件夹(如库和桌面)的工作方式如下:

.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) Environment.GetFolderPath永远不会返回MyComputer的路径,因为它实际上没有路径.

从MSDN documentation:

The MyComputer constant always yields the empty string (“”) because no
path is defined for the My Computer folder.

这意味着您的解决方案是最好的(并且可能是没有太多人知道​​的解决方案).为了将来的兴趣,here is a link到可用的CLSID列表.