我试图让进程响应为一个字符串,所以我可以在我的代码中的不同位置使用它,这是我到目前为止的解决方案:
const string ex1 = @"C:\Projects\MyProgram.exe "; const string ex2 = @"C:\Projects\ProgramXmlConfig.xml"; Process process = new Process(); process.StartInfo.WorkingDirectory = @"C:\Projects"; process.StartInfo.FileName = "MyProgram.exe "; process.StartInfo.Arguments = ex2; process.StartInfo.Password = new System.Security.SecureString(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; try { process.Start(); StreamReader reader = process.StandardOutput; string output = reader.ReadToEnd(); } catch (Exception exception) { AddComment(exception.ToString()); }
但是当我跑步时,我得到:
06001
代码运行正常,但它只是打开控制台窗口,所有进程响应都在那里,因此我不能将它用作字符串.