title: File.Open vs new FileStream()
body: <p>I know <code>File.Open()</code> internally calls <code>new FileStream()</code>. So why does code utilizing <code>File.Open()</code> throw an <code>IOException</code> with the error message: </p>
  
  <blockquote>
    <p>The process cannot access the file because it is being used by another process</p>
  </blockquote>
  
  <p>Code with using <code>FileStream()</code> does not cause this error.</p>
  
  <pre><code>for (int i = 0; i &lt; 20000; i++)
  {
      XmlSerializer x1 = new XmlSerializer(typeof(Tasks));
      using (FileStream fileStream = File.Open(
               Settings.Default.DownloadJobFileName,
               FileMode.Open, 
               FileAccess.Read))
          {
              tasks = ((Tasks)xmlSerializer.Deserialize(fileStream));
          }
  
      XmlSerializer x2 = new XmlSerializer(typeof(Tasks));
      using (FileStream fileStream = File.Open(
                Settings.Default.DownloadJobFileName,
                FileMode.Create, 
                FileAccess.Write))
          {
              xmlSerializer.Serialize(fileStream, tasks);
          }
  }
  </code></pre>
  
  <p>I'm using Windows 8.1 and .Net 4.0 client profile, seems it's getting worse on Windows Embedded Standard 2009</p>