public static void launchProcess(string processName, string arguments, out string output)
{
Process p = new Process
{
StartInfo = { UseShellExecute = false, RedirectStandardOutput = true, FileName = processName, Arguments = arguments }
};
p.Start();
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
And if my arguments contains the file names like:
D:\Visual Studio Projects\ProjectOnTFS\ProjectOnTFS
Then I get the error:
Use quotation marks when specifying long filenames or paths with spaces. For example, typing the copy c:\my file name d:\my new file name command at the command prompt results in the following error message: The system cannot find the file specified. The quotation marks must be used.
When you send arguments, those with poison or space characters need to be doublequoted. Inside your batch file, if you no longer need the surrounding doublequotes, you'd remove them by using %~5 instead of %5 . Additionally the recommended syntax for the set command is Set "VariableName=VariableValue" .
Enclose the paths containing spaces with double quotes.
It'll need doubles quotes, but will also likely need an @ to treat the string word-for-word (verbatim string) i.e. the "\" has a special meaning in string e.g. \t means a tab, so we want to ignore the \
So not only the double quotes, but also @
string myArgument = @"D:\Visual Studio Projects\ProjectOnTFS\ProjectOnTFS";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With