문제

Passing in a value with a comma in the UNC path (e.g. "\servername\Smith,John\Documents\") causes the following to start windows explorer but it opens the My Documents instead of the folder path. If I paste in the path into windows explorer's address bar, the folder opens appropriately.

public void OpenWindowsExplorer(string path) {
        var runExplorer = new ProcessStartInfo { FileName = "explorer.exe", Arguments = path };
        Process.Start(runExplorer);
    }

Any idea as to why this is happening/how to resolve the issue is greatly appreciated.

도움이 되었습니까?

해결책

Put quotes around the path:

public void OpenWindowsExplorer(string path) {
    path = string.Format("\"{0}\"", path);
    var runExplorer = new ProcessStartInfo { FileName = "explorer.exe",
                                             Arguments = path };
    Process.Start(runExplorer);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top