【发布时间】:2019-06-25 06:38:21
【问题描述】:
我有一个 exe 文件,我使用 c# 中的 Process 命名空间从我的 c# 代码中调用它。
我使用 ReadToEnd() 方法捕获输出。 (在 exe 源代码中,我使用了打印方法来获得所需的输出)。
问题是当我的输出变大时,exe 文件的执行会崩溃并挂起。
调用exe函数时输出大小有限制吗?
Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = args;
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return output;
【问题讨论】:
-
首先,您需要实际阅读 documentation 以完成此特定任务。另一件事是我相信您应该尝试采用异步方法,也可以找到here
-
你得到的错误/异常是什么?
-
我没有收到任何错误消息。但是运行 exe 文件时的控制台页面会永远保留。