C# 由我的程序启动的批处理文件进程不';t返回完整输出
我编写了一个批处理文件,它使用将输出返回到cmd窗口的方法 但是,当我从Windows窗体程序(用C#编写)将此文件作为进程启动时,返回的输出不是cmd窗口中的输出C# 由我的程序启动的批处理文件进程不';t返回完整输出,c#,batch-file,process,output,C#,Batch File,Process,Output,我编写了一个批处理文件,它使用将输出返回到cmd窗口的方法 但是,当我从Windows窗体程序(用C#编写)将此文件作为进程启动时,返回的输出不是cmd窗口中的输出 例如: 从cmd窗口:“错误:未找到设备/模拟器” 来自输出字符串:“”(本例中没有输出,不同的情况-只是输出的一部分) 如何获得此批处理文件的完整输出?看起来您应该使用 process.StandardError.ReadToEnd(); 和 process.StandardOutput.ReadToEnd(); 说明:
例如: 从cmd窗口:“错误:未找到设备/模拟器” 来自输出字符串:“”(本例中没有输出,不同的情况-只是输出的一部分)
如何获得此批处理文件的完整输出?看起来您应该使用
process.StandardError.ReadToEnd();
和
process.StandardOutput.ReadToEnd();
说明:
每个应用程序有两个输出,stdout和stderr
- 标准输出用于通用输出李>
- 标准错误是指错误
[...]
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
if(!error.equals(""))
throw new Exception(error);
return output;
看起来你应该使用
process.StandardError.ReadToEnd();
和
process.StandardOutput.ReadToEnd();
说明:
每个应用程序有两个输出,stdout和stderr
- 标准输出用于通用输出李>
- 标准错误是指错误
[...]
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
if(!error.equals(""))
throw new Exception(error);
return output;