I am using a third party software tool (command line tool) to merge PDF files together. Using C# I am attempting to use System.Diagnostics.Process to run the executable but I am coming up with a few errors depending on the parameter setup.
- If
UseShellExecute = trueandRedirectStandardOutput = trueI get:- The Process object must have the
UseShellExecuteproperty set tofalsein order to redirect IO streams.
- The Process object must have the
- If
UseShellExecute = trueandRedirectStandardOutput = falseI get:- The system cannot find the file specified
- If
useShellExecute = falseandRedirectStandardOutput = trueI get:- The system cannot find the file specified
- If
UseShellExecute = falseandRedirectStandardOutput = falseI get:- The system cannot find the file specified
The code that is running is the following:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.WorkingDirectory = "C:\\Program Files (x86)\\VeryPDF PDF Split-Merge v3.0";
p.StartInfo.FileName = "pdfpg.exe " + strFileNames.Trim() + " "
+ D2P_Folder_Converted + "\\" + strOutputFileName;
p.Start();
p.WaitForExit();
p.Close();
p.Dispose();
Can someone help me get around this issue, please?
Arguments shouldn’t be passed in the FileName property. You should use the Arguments property for this:
where the
GetProgramFilesX86function is could be defined like so: