System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName="id";
proc.StartInfo.Arguments="-un";
proc.Start();
string nome_user = proc.StandardOutput.ReadLine();
proc.WaitForExit();
Hi, I was trying to run a shell command using Mono GTK#. When the debugger is on the proc.Start(); line, proc.StandardOutput.ReadLine() added to watch shows the output correctly, but when the debugger jumps to the next line (string nome_user = proc.StandardOutput.ReadLine();), with no reason the value of the proc.StandardOutput.ReadLine() turns into null. Can you help me?
Well, if you read it in the debugger, it’s already been consumed from the stream. The stream won’t magically rewind so it can be read again.