繁体   English   中英

如何将Windows资源管理器打开到用户指定的特定目录?

[英]How can I open windows explorer to a certain directory specified by user?

我的代码

string pcname = @"remotepc";
string path = @"dir\sub\";
string remotepath = @"\\" + pcname + @"\C$\" + path;

System.Diagnostics.Process pexplorer = new System.Diagnostics.Process();
pexplorer.StartInfo.FileName = "explorer.exe";
pexplorer.StartInfo.Arguments = remotepath;
pexplorer.Start();

remotepath包含类似“ \\\\ remotepc \\ C $ \\ dir \\ sub”的字符串。 如果我将此字符串复制到Windows资源管理器的addressbar ,它将显示此目录。

但是进入我的程序,资源管理器是在主目录中打开的。 当我查看pexplorer.StartInfoArguments ,它包含类似“ \\\\\\\\ remotepc \\\\ C $ \\\\ Users \\\\ use \\\\ AppData \\\\ Local \\\\”的内容。

如果我在程序中设置了remotepath

System.Diagnostics.Process pexplorer = new System.Diagnostics.Process();
pexplorer.StartInfo.FileName = "explorer.exe";
pexplorer.StartInfo.Arguments = @"\\remotepc\C$\dir\sub";
pexplorer.Start();

它可以正常工作,这是怎么了?

Process p = new Process();
p.StartInfo.FileName = @"explorer.exe";
p.StartInfo.Arguments = @"file:\\\" + @"Q:\somepath\...";
p.Start();

问题纯粹是URL。 在您的完整路径中添加“ file:\\\\”确实解决了我的问题。 http://blogs.msdn.com/b/freeassociations/archive/2005/05/19/420059.aspx csharphardcoreprogramming.wordpress.com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM