I have a C# application, which accesses the command line tool "cppcheck" and is then supposed to save the output of this command line tool to the variable "output".
Here is the code:
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();
The problem is that the function ReadToEnd() does in fact not appear to read to the end ... instead it stops before the important part that I need.
Here is the total output of cppcheck:
But only the upper part of this text gets saved into variable "output", namely this part:
How can I catch the whole output of cppcheck?
You should also hook into Process.StandardError
string error = p.StandardError.ReadToEnd();