I have trouble executing a command via c#. The command consists of two paths, which I have to combine. Both paths contain spaces.
String arguments = "/K \"" + dtExecPath + "\"" + @" /f " + "\"" + tmpPackagePath + "\"";
// arguments = AddQuotesIfRequired(arguments);
Console.WriteLine("TEST: " + arguments);
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = @arguments;
process.StartInfo = startInfo;
process.Start();
When I execute the code, I get the following error: ""C:\Program" could not be found.
The generated command looks like this:
TEST: /K "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\DTEXEC.exe" /f "C:\Users\toki\source\repos\Integration Services Project1\Integration Services Project1\tmp\O2Data (1).dtsx"
What's the error?