title: File.Exists returns true after File.Delete
body: <p>I have the following method to delete a file with a provided path</p>
  
  <pre><code>private void DestroyFile(string path)
  {
      try
      {
          if (File.Exists(path))
          {
              File.Delete(path);
          }
          if (File.Exists(path))
          {
              throw new IOException(string.Format("Failed to delete file: '{0}'.", path));
          }
      }
      catch (Exception ex)
      {
          throw ex;
      }
  }
  </code></pre>
  
  <p>I am getting the IOException that is thrown if the file exists after the File.Delete method. Specifically</p>
  
  <blockquote>
    <p>System.IO.IOException): Failed to delete file: 'C:\Windows\TEMP\[FILE NAME]'.</p>
  </blockquote>
  
  <p>I have also confirmed that the file does not exist at the location in the path variable after the execution is complete. I am wondering if I am running up against a race condition between the file system updating after File.Delete and checking against it again with File.Exists. Is there a better way to smoothly delete? I know that File.Delete won't return an error if the file doesn't exist so maybe these checks are a bit redundant. Should I check if the file is in use rather than if it exists at all?</p>
  
  <p>Some important additional information:
  The program can and does run successfully often but this particular error has been frequently seen recently.</p>