title: Do I need to use FileStream.Flush() or FileStream.Flush(true)?
body: <p>In my program, I write a file, then call an external program that reads that file. Do I need <a href="http://msdn.microsoft.com/en-us/library/ee474552(v=vs.110).aspx" rel="nofollow"><code>Flush(true)</code></a> to make sure that the data is written entirely to disk, or is <a href="http://msdn.microsoft.com/en-us/library/2bw4h516(v=vs.110).aspx" rel="nofollow"><code>Flush()</code></a> sufficient?</p>
  
  <pre><code>class ExampleClass : IDisposable {
      private FileStream stream = File.Open("command-list.txt", FileMode.Append, FileAccess.Write, FileShare.Read);
  
      public void Execute(string command) {
          var buffer = Encoding.UTF8.GetBytes(command);
          stream.WriteByte(10);
          stream.Write(buffer, 0, buffer.Length);
          stream.Flush(true);
          Process.Start("processor", "command-list.txt");
      }
  
      public void Dispose() {
          stream.Close();
      }
  }
  </code></pre>