Frage

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.

War es hilfreich?

Lösung

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);
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top