我用了两个GUID来打开文件夹的我的电脑的和的我的文档的。

Process.Start("iexplore.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("iexplore.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");

但它打开Internet Explorer,然后打开文件夹的我的电脑的和的我的文档的。

有帮助吗?

解决方案

更好的是将完全跳过explorer,只是“开始”直接的GUID:

... Process.Start("::{20d04fe0-3aea-1069-a2d8-08002b30309d}");

其他提示

使用这些硬编码GUID值并不像实现这一目标的最佳途径。

您可以使用 Environment.GetFolderPath 函数来获取路径任何系统特殊文件夹。它接受一个 Environment.SpecialFolder 枚举

这样,它会更强劲,因为你不会有任何“神奇”的硬编码值。

下面是你如何使用它:

//get the folder paths
string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
//open explorer and point it at the paths
System.Diagnostics.Process.Start("explorer", myComputerPath);
System.Diagnostics.Process.Start("explorer", myDocumentsPath);

对于Windows 重要说明7用户

这似乎在尝试使用此代码,打开Windows 7上我的电脑错误导致被打开的文件夹,而不是库。这是因为,正在运行的浏览器的一个空路径默认行为在Windows 7已经改变。

我在连接上提交下列错误报告,去给它一个给予好评,如果你认为这是很重要的!

https://connect.microsoft.com/VisualStudio/feedback/details/757291/environment-getfolderpath-not-working-correctly-in-windows-7#details

(感谢JeremyK在指出这一点的评论)

你试过:

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("explorer.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");

尝试的explorer.exe:

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("explorer.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");

这不适合我的Vista工作:

string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
System.Diagnostics.Process.Start("explorer", myComputerPath);

如Environment.SpecialFolder.MyComputer返回 “” 和的Process.Start( “资源管理器”, “”)打开我的文档。

在GUID似乎这样做,虽然:

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
System.Diagnostics.Process.Start("...");

我知道它看起来令人怀疑,但只要运行它。它会工作。这是我的计算机代码。我不知道它应该是什么的我的文档的。

  

System.Diagnostics.Process.Start("...");

我知道它看起来令人怀疑,但只要运行它。它会工作。这是我的计算机代码。我不知道它应该是什么我的文档。

在视窗7,这导致从打开你的可执行运行的位置的文件夹,即“当前”的文件夹。

我不得不打开我的文档,并根据上述评论我缩小溶液打开资源管理无副作用:

Process.Start("::{450d8fba-ad25-11d0-98a8-0800361b1103}");

我测试了它在Windows Server 2008 R2。

Samdoss

刚进入

System.Diagnostics.Process.Start(directoryPath);

它很容易。尝试。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top