我需要使用C#通过Windows资源管理器打开文件夹.它工作正常,直到文件夹路径中有逗号.这是一个例子:
System.Diagnostics.Process.Start("explorer.exe", "C:\\folder\\another-folder\\123,456");
Run Code Online (Sandbox Code Playgroud)
错误是:路径'456'不存在或它不是目录.
任何解决方案请:)
Hos*_*Aly 15
尝试在路径周围添加双引号:
System.Diagnostics.Process.Start("explorer.exe", "\"C:\\folder\\another-folder\\123,456\"");
Run Code Online (Sandbox Code Playgroud)
附注:您可能会发现使用逐字字符串文字编写路径更容易,以避免必须转义斜杠:
System.Diagnostics.Process.Start("explorer.exe", @"""C:\folder\another-folder\123,456""");
Run Code Online (Sandbox Code Playgroud)
尝试用双引号将路径引起来:
System.Diagnostics.Process.Start("explorer.exe", "\"C:\\folder\\another-folder\\123,456\"");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3078 次 |
| 最近记录: |