title: StreamWriter doesn't write to a file that doesn't exist
body: <p>I am making a level editor for my game, and most of it is working except...
  When I try to save my file (XML) the file doesn't get created, and in the output box I get:</p>
  
  <p><code>A first chance exception of type 'System.NullReferenceException'</code></p>
  
  <p>The funny thing is that it only happens if the file doesn't exist, but it works correctly if I overwrite another file.</p>
  
  <p>here is the code I'm using:</p>
  
  <pre><code>using (StreamWriter stream = new StreamWriter(filePath))
  {
      stream.Write(data);
      stream.Close();
  }
  </code></pre>
  
  <p>data is a string (this is not the problem because it works when I overwrite the file)</p>