title: File is already in use FileAccess C#
body: <pre><code>public void WriteListToFile(Lists lists, string filePath)
      {
          FileStream outFile;
          BinaryFormatter bFormatter = new BinaryFormatter();
  
          // Ppen file for output
          outFile = new FileStream(filePath, FileMode.Create, FileAccess.Write);
  
          // Output object to file via serialization
          bFormatter.Serialize(outFile, lists);
  
          // Close file
          outFile.Close();
      }
  </code></pre>
  
  <p>Whenever I try to output data to a <code>.dat</code> file I get an error saying that the file is already in use. How do I fix this?</p>
  
  <p>EDT: Turns out it wouldn't let me save to an empty file so I create a new void to input data and then it allowed me to save over the file.</p>