I am trying to pass file path as command line argument. If the path without spaces it works fine, but with spaces it is not. In below code commandText "scriptPath" is working even with spaces. But the variables "file1" & "file2" are not working with spaces.
string scriptFilePath = "@" + string.Format("\"{0}\"", "D:\\Script\\ScriptFile.txt");
string file1 = @"D:\New Folder\file1.png";
string file2 = @"D:\New Folder\file2.png";
string outPutPath = @"D:\New Folder\Output\Report.html";
string commandText = "/c " + "BCompare.exe" + scriptFilePath + " " + file1 + " " + file2 + " " + outPutPath;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = @exePath;
startInfo.FileName = "cmd.exe";
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.Arguments = commandText;
proc = Process.Start(startInfo);
proc.WaitForExit();