Omar El-elamy Omar El-elamy - 1 month ago 18
C# Question

File Path with spaces in process writeline

i wanted to ask a question related to passing a file path with spaces in the cmd... i have this statement that i want to execute


nunit3-console.exe "E:/folder 1/folder2"


i want to know how can i put double quotes to the file path as folder 1 has white space in between.. i'm using now

process.StandardInput.WriteLine("nunit3-console.exe E:/folder1/Report_Testing.dll");


this works if the folder doesn't have spaces.. what is the solution to execute the above command with " " .. Thanks in advance

Jon Jon
Answer

If you put a backslash before a double quote then a double quote will be included in the string.

i.e.:

process.StandardInput.WriteLine("nunit3-console.exe \"E:/folder1/Report_Testing.dll\"");

Refer to https://msdn.microsoft.com/en-us/library/h21280bw.aspx for more information.

Comments