开发者

Open folder which contains comma in its path

I need to open folder through windows explorer开发者_如何学Go using C#. It is working fine untill there is comma in folder path. Here is an example:

System.Diagnostics.Process.Start("explorer.exe", "C:\\folder\\another-folder\\123,456");

The error is: The path '456' does not exist or it is not a directory.

Any solution please :)


Try adding double quotes around your path:

System.Diagnostics.Process.Start("explorer.exe", "\"C:\\folder\\another-folder\\123,456\"");

Side-note: you might find it easier to write paths using a verbatim string literal, to avoid having to escape the slashes:

System.Diagnostics.Process.Start("explorer.exe", @"""C:\folder\another-folder\123,456""");


Try to surround the path with double-quotes:

System.Diagnostics.Process.Start("explorer.exe", "\"C:\\folder\\another-folder\\123,456\"");


Try escaping the file name:

System.Diagnostics.Process.Start("explorer.exe", "\"C:\\folder\\another-folder\\123,456\"");


Use the @ operator before the path string ...and then simply write down the path without any escape characters like backslashes etc. It makes the string verbatim.

System.Diagnostics.Process.Start(@"C:\myapp.exe"); // should work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜