title: How to check if System.IO.File.Delete deleted a file successfully
body: <p>After removing a file using the system.io.file class:</p>
  
  <pre><code>System.IO.File.Delete(openedPdfs.path);
  </code></pre>
  
  <p>I need to run some code if the file was sucessfully deleted.
  As long as the method does not return any value, I am checking if the file exist after the delete method. If it still exist I supposed the operation had failed.</p>
  
  <p>The problem is, the deletion method works fine, but there is a couple of seconds to the file to be deleted. The Exist function return true because at the time it is checking the file is there.</p>
  
  <p>How can I verify for sure if the <code>System.IO.File.Delete(openedPdfs.path);</code> completed successfully?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>FileInfo file = new FileInfo(openedPdfs.path);    
  System.IO.File.Delete(openedPdfs.path);
  if (file.Exists == false)
  { ... }
  else 
  { ... }
  </code></pre>