C# process.StandardOutput.ReadToEnd()未获取全部StandardOutput
我有一个C#应用程序,它访问命令行工具“cppcheck”,然后将此命令行工具的输出保存到变量“output” 代码如下:C# process.StandardOutput.ReadToEnd()未获取全部StandardOutput,c#,visual-studio,cppcheck,C#,Visual Studio,Cppcheck,我有一个C#应用程序,它访问命令行工具“cppcheck”,然后将此命令行工具的输出保存到变量“output” 代码如下: System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "cmd
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C cppcheck" + " \"" + currentEvent.currentEventFilePath + "\"";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
process.StartInfo = startInfo;
process.Start();
//the following line is the problem. Output of cppcheck is not completely read:
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
问题是函数ReadToEnd()实际上看起来并没有读到底。。。相反,它会在我需要的重要部分之前停止
以下是cppcheck的总输出:
但只有文本的上半部分保存到变量“output”中,即这一部分:
如何捕获cppcheck的全部输出?您还应该连接到
你也应该加入
非常感谢你的回答。但是警告呢?它们是否也包含在“p.StandardError.ReadToEnd();”中?非常感谢您的回答。但是警告呢?它们是否也包含在“p.StandardError.ReadToEnd();”中?
string error = p.StandardError.ReadToEnd();