您好我已启动参数分析软件CFast。为此,我想在C#中创建一个运行核心CFast.exe的应用程序。如果我想从cmd.exe运行该软件并在文件INPUTFILENAME.in上执行它我写入提示:
CFast.exe INPUTFILENAME
在C#中,我编写了以下代码:
Process firstProc = new Process();
firstProc.StartInfo.FileName = @"C:\Users\Alberto\Desktop\Simulazioni Cfast\D\C\N\A3B1\CFAST.exe";
firstProc.StartInfo.Arguments = @"INPUTFILENAME";
firstProc.EnableRaisingEvents = true;
firstProc.Start();
firstProc.WaitForExit();
使用此代码运行CFast但没有分析任何东西......似乎不接受这个论点。提示这个麻烦?
答案 0 :(得分:0)
解决。文件名和命令语法中的错误
// setup cmd process
var command = @"CFAST.exe C:\Users\Alberto\Desktop\Simulazioni_Cfast\D\C\N\A3B1\A3B1";
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardError = true;
procStartInfo.CreateNoWindow = true;
// start process
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
// read process output
string cmdError = proc.StandardError.ReadToEnd();
string cmdOutput = proc.StandardOutput.ReadToEnd();
其中A3B1是文件名.IN