title: Get Live output from Process
body: <p>I've a problem in my project. I would like to launch a process, 7z.exe (console version).
  I've tried three different things:</p>
  
  <ul>
  <li>Process.StandardOutput.ReadToEnd();</li>
  <li>OutputDataReceived &amp; BeginOutputReadLine</li>
  <li>StreamWriter</li>
  </ul>
  
  <p>Nothing works. It always "wait" for the end of the process to show what i want.
  I don't have any code to put, just if you want my code with one of the things listed upthere. Thanks.</p>
  
  <p>Edit:
  My code:</p>
  
  <pre><code>        process.StartInfo.UseShellExecute = false;
          process.StartInfo.RedirectStandardOutput = true;
          process.StartInfo.CreateNoWindow = true;
          process.Start();
  
          this.sr = process.StandardOutput;
          while (!sr.EndOfStream)
          {
              String s = sr.ReadLine();
              if (s != "")
              {
                  System.Console.WriteLine(DateTime.Now + " - " + s);
              }
          }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>process.StartInfo.UseShellExecute = false;
  process.StartInfo.RedirectStandardOutput = true;
  process.OutputDataReceived += new DataReceivedEventHandler(recieve);
  process.StartInfo.CreateNoWindow = true;
  process.Start();
  process.BeginOutputReadLine();
  process.WaitForExit();
  public void recieve(object e, DataReceivedEventArgs outLine)
  {
      System.Console.WriteLine(DateTime.Now + " - " + outLine.Data);
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>process.StartInfo.UseShellExecute = false;
  process.StartInfo.RedirectStandardOutput = true;
  process.Start();
  string output = p.StandardOutput.ReadToEnd();
  process.WaitForExit();
  </code></pre>
  
  <p>Where "process" is my pre-made Process</p>
  
  <p>Ok i know why it doesn't works properly: 7z.exe is the bug: it display a percent loading in console, and it sends information only when the current file is finished. In extraction for example, it works fine :). I will search for another way to use 7z functions without 7z.exe (maybe with 7za.exe or with some DLL). Thanks to all.
  To answer to the question, OuputDataRecieved event works fine !</p>