title: How do I overwrite a file if it already exists?
body: <p>I'm making a text editor using fastColoredTextbox. I have a button that allows you to save your text onto your pc. The problem is that it throws an exception when the user tries to save the file as a file that already exists, instead of overwriting the file.</p>
  <p>This is my code.</p>
  <pre class="lang-js prettyprint-override"><code>SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  saveFileDialog1.Filter = &quot;txt|*.txt|All files|*.*&quot;;
  if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  {
      using (Stream s = File.Open(saveFileDialog1.FileName, FileMode.CreateNew))
      using (StreamWriter sw = new StreamWriter(s))
      {
          sw.Write(fastColoredTextBox1.Text);
      }
  }
  </code></pre>
  <p>How would I go about making it overwrite the file if it already exists?</p>