我已经回答了类似的问题a coupletimes before的:。
,这里是我以前的答案只需更换与会代表改为写入文件。
ProcessStartInfo processInfo = new ProcessStartInfo("Myexe.exe");
processInfo.ErrorDialog = false;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.RedirectStandardError = true;
Process proc = Process.Start(processInfo);
// You can pass any delegate that matches the appropriate
// signature to ErrorDataReceived and OutputDataReceived
proc.ErrorDataReceived += (sender, errorLine) => { if (errorLine.Data != null) Trace.WriteLine(errorLine.Data); };
proc.OutputDataReceived += (sender, outputLine) => { if (outputLine.Data != null) Trace.WriteLine(outputLine.Data); };
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
proc.WaitForExit();
在您的特定情况下,请不要忘记从命令行中删除“> C:\\mydir\\test.txt
”。
您是否有任何证据表明Perl脚本能正常运行?如果是这样,我怀疑这确实是一个C#问题。否则,我会首先验证Perl脚本是否正确。 – 2011-05-03 18:34:19
perl脚本是正确的,因为如果我使用命令行执行它,它的工作原理。 – CSharpTag 2011-05-03 18:42:51