mat*_*con 3 system.diagnostics process processstartinfo
我正在使用第三方软件工具(命令行工具)将PDF文件合并在一起.使用C#我试图用来System.Diagnostics.Process运行可执行文件,但我想出了一些错误,具体取决于参数设置.
UseShellExecute = true和RedirectStandardOutput = true我得到:
UseShellExecute属性设置为false以重定向IO流.UseShellExecute = true和RedirectStandardOutput = false我得到:
useShellExecute = false和RedirectStandardOutput = true我得到:
UseShellExecute = false和RedirectStandardOutput = false我得到:
正在运行的代码如下:
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();
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?
当UseShellExecute为false时,WorkingDirectory属性会更改其含义!它成为新进程的工作目录而不是可执行文件的路径.您需要在FileName属性中指定可执行文件的完整路径.