【发布时间】:2010-12-08 05:36:06
【问题描述】:
我正在尝试让以下代码工作,以便我可以从我的 c#程序。我正在 xp service pack3 上使用 Visual stdio 2008 进行开发。
myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("perl.exe");
myProcessStartInfo.Arguments = @"C:\Documents and Settings\test_perl.pl";
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcessStartInfo.CreateNoWindow = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
string output = myProcess.StandardOutput.ReadToEnd();
MessageBox.Show(output);
myProcess.WaitForExit();
我验证了 test_perl.pl 是否存在,如果我将 perl.exe 更改为 notepad.exe,上面的代码就可以工作。但是如果我使用 perl.exe,消息框是空的。
无法弄清楚为什么这是错误的。如果您知道原因,请帮助我。
谢谢
【问题讨论】:
标签: c# perl processstartinfo