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

C# 如何将windows资源管理器打开到用户指定的特定目录?,c#,directory,explorer,C#,Directory,Explorer,我的代码 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.Start

我的代码

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资源管理器的地址栏中,它将显示此目录

但是进入我的程序浏览器是在主目录中打开的。 当我查看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。将文件:\\添加到完整路径确实解决了我的问题。
csharphardcoreprogramming.wordpress.com

一个技巧。不要自己连接路径。相反,请使用System.IO.Path.Combine。e、 g.var uncPath=System.IO.Path.Combine@\\,pcname,c$,Path;我在这两个代码块中看到的唯一区别是,第一个路径包含一个尾随的反斜杠。第二个代码块没有。如果我错误地说出了路径的某些部分,我可以重现您的症状。在这种情况下,资源管理器将打开本地文档文件夹。所以,检查你的路径是否正确。我同意@Steve。尾随反斜杠没有任何区别。在这两种情况下,它都可以工作。@吸毒者System.IO.Path.Combine不能接受超过3个参数。我应该联合收割机吗?