Passing quotes in Process.Start arguments

string sourcePath = @"c:\z\b";
string targetPath = @"c:\z\a";

string arguments = string.Format("\"{0}\" \"{1}\"", sourcePath, targetPath);

var p = Process.Start("cmd", "/C mklink /H " + arguments);

Working example:

string sourcePath = @"c:\documents and settings\harvey robert\My Documents\Test.txt";
string targetPath = @"c:\test";

string s = string.Format("\"{0}\" \"{1}\"", sourcePath, targetPath);
Process.Start("cmd", @"/c copy " + s);

1 files copied.

Leave a Comment