title: Process standard output in C# returning empty string
body: <p>I'm trying to list the supported interfaces on which dumpcap.exe can capture data.</p>
  
  <p>The command i want to run is "dumpcap.exe -D"</p>
  
  <p>On my system, it gives the output as :-</p>
  
  <pre><code>1. \Device\NPF_{1B627AA8-2A1D-4C90-B560-517CF71B33A5} (Intel(R) 825
  Network Connection)
  2. \Device\NPF_{7ECC4D31-DF17-49AB-960D-628D0580F3C6} (Microsoft)
  </code></pre>
  
  <p>I'm trying to read the above output by runing the same command from a WPF C# application. I have the following code to do so:-</p>
  
  <pre><code>        Process proc = new Process();
  
          //set the path to dumpcap.exe (verified by me)
          proc.StartInfo.FileName = "..\\..\\..\\..\\..\\Dumpcap\\dumpcap.exe";
  
          StringBuilder dumpcapArgs = new StringBuilder();
  
          dumpcapArgs.Append("-D");
  
          proc.StartInfo.Arguments = dumpcapArgs.ToString();
          proc.StartInfo.CreateNoWindow = true;
          proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
          proc.StartInfo.RedirectStandardOutput = true;
          proc.StartInfo.UseShellExecute = false;
  
          proc.Start();
  
          while (!proc.StandardOutput.EndOfStream)
          {
              string line = proc.StandardOutput.ReadLine();
              MessageBox.Show(line);
  
          }
  </code></pre>
  
  <p>When i debug, the execution does not go in my while loop at all. The StandardOutput is already at the end of stream. Digging further into StandardOutput base stream class members, i see a lot of System.NotSupportedExceptions in length, position etc.</p>
  
  <p>What is possibly wrong with the above code?</p>
  
  <p><strong>Quick Observation</strong></p>
  
  <p>I tried another sample C# console application with the following code:</p>
  
  <pre><code>        Process proc = new Process();
  
          proc.StartInfo.FileName = "C:\\Karan\\Dumpcap\\dumpcap.exe";
          proc.StartInfo.Arguments = "-D";
          proc.StartInfo.UseShellExecute = false;
          proc.StartInfo.RedirectStandardOutput = true;
          proc.Start();
  
          Console.WriteLine(proc.StandardOutput.ReadToEnd());
  
          proc.WaitForExit();
  </code></pre>
  
  <p>This prints the output as expected!</p>
  
  <p>However, if i try to read the standardoutput in a string variable, i get an empty string.</p>
  
  <p>For example, this returns me an empty string:-</p>
  
  <pre><code>       Process proc = new Process();
  
          proc.StartInfo.FileName = "C:\\Karan\\Dumpcap\\dumpcap.exe";
          proc.StartInfo.Arguments = "-D";
          proc.StartInfo.UseShellExecute = false;
          proc.StartInfo.RedirectStandardOutput = true;
          proc.Start();
  
  
          String output = proc.StandardOutput.ReadToEnd();
  
  
          proc.WaitForExit();
  </code></pre>