I create the process this way:
Process process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "cmd",
Arguments = "/C tools\\adb " + serial + command,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
}
};
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
Then I subscribe to the event:
process.OutputDataReceived += Display;
I append the data to the StringBuilder:
builder.AppendLine(e.Data);
Finally i append the StringBuilder text to a RichTextBox.
rtb_console.AppendText(builder.ToString());
The problem is, that the the output I get is not equal to the output i get with cmd.
E.g.
CMD (correct):
Line 1 text text text text
Line 2 text text text text
Line 3 text text text text
With C# (wrong):
Line 1 text text text text
Line 2 text text text text
Line 3 text text text text
I also get the wrong output, when I execute
adb logcat -d > output.txt
The problem does not occur, if I use StandardOutput.ReadToEnd(), but then I will not get the live output.
I can not find the problem. Can you help me?
Sincerely