title: How to use C# Stream Reader to save a completion of a process?
body: <p>I have a program which uses a CMD program to execute various arguements.</p>
  
  <p>The arguements that would work in a normal CMD would be C:\temp\bin\fls.exe -m C: -r C:\temp\image.dd > C:\temp\bin\ntfs.bodyfile .</p>
  
  <p>The C# program that I have written only works till  C:\temp\bin\fls.exe -m C: -r C:\temp\image.dd but does not execute the > C:\temp\bin\ntfs.bodyfile which means save the process into the ntfs.bodyfile.</p>
  
  <p>I have read many other websites and they all point to the problem of my program missing a streamreader to save the completion of the process into a file. So can someone please advise on my program to allow the process to be saved into a file? Thanks!</p>
  
  <p>One such similar website that has a same problem would be: <a href="https://stackoverflow.com/questions/1521725/streamreader-to-file">StreamReader to file?</a></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Microsoft.Win32;
  using System.Diagnostics;
  
  namespace ConsoleApplication1
  {
  class Program
  {
     static void Main(string[] args)
     {
         Process process = new Process();
         process.StartInfo.FileName = "C:\\temp\\bin\\fls.exe";
         process.StartInfo.Arguments = "-m C: -r C:\\temp\\image.dd &gt; 
         C:\\temp\\bin\\ntfs.bodyfile";
         process.StartInfo.UseShellExecute = false;
         process.StartInfo.RedirectStandardOutput = true;
         process.StartInfo.RedirectStandardInput = true;
         process.StartInfo.RedirectStandardError = true;
         process.Start();
  
         System.IO.StreamReader reader = process.StandardOutput;
         string sRes = reader.ReadToEnd();
         Console.WriteLine(sRes);
         reader.Close();  
     }   
   }
  }
  </code></pre>