我已经调用一个FORTRAN可执行的处理。可执行文件向用户请求一个文件并执行操作以查找解决方案。如果在文件中找到多个解决方案,程序会询问用户是否想要找到最佳解决方案,基本上该程序有两个输入。然后可执行文件生成一个提供程序结果的文本文件。C#过程不接收输入
过程是能够运行,但不会产生结果文本文件。此外,当我检查应用程序的输出,信息提示(“输入文件”)是存储在字符串中的唯一的事情,它不包含最优解的二次提示(“你想找到最优解决方案?“)。任何人都可以给我一个想法,为什么会发生这种情况?谢谢。
Process exeProcess = new Process();
exeProcess.StartInfo.FileName = "sdf45.exe";
exeProcess.StartInfo.UseShellExecute = false;
exeProcess.StartInfo.RedirectStandardError = true;
exeProcess.StartInfo.RedirectStandardInput = true;
exeProcess.StartInfo.RedirectStandardOutput = true;
exeProcess.Start();
//input file
exeProcess.StandardInput.WriteLine(Path.GetFileName(filePath));
//find optimal solution
exeProcess.StandardInput.WriteLine("Y");
string output = exeProcess.StandardOutput.ReadToEnd();
exeProcess.WaitForExit();
如何执行请求来自用户的文件吗? – Tigran 2012-02-20 20:50:28
所以我看到你在不阅读它的情况下重定向标准错误。如果程序写很多标准错误,这可能会导致问题。 – Servy 2012-02-20 20:52:03
可执行文件要求提供与可执行文件位于同一目录中的文件的名称。 – BeingIan 2012-02-20 20:52:57