title: c# - Process cannot access file because it is used by another process
body: <p>This is the scenario, 
  I have an application that overwrites an xml file every 2secs.
  And then I have this c# application, that reads this file every 1-2secs.
  this process runs fine, but there are times when i get the error saying,</p>
  
  <blockquote>
    <p>Process cannot access file because it is used by another process</p>
  </blockquote>
  
  <p>I am using xmldocument.load to open and read the xml file.</p>
  
  <p>What can i do to solve this issue?
  I have tried running on different machines, and this is absolutely random, as on my machine, it ran for 6 hours before the error, on another machine, </p>
  
  <p>Coz my c# program will continue reading this file, unless the user click a button to stop the data logging process</p>
  
  <p>As i want the program to continue running as long as the user doesn't stop it.
  Please help</p>