title: How to use FileSystemWatcher to check whether a file is locked by another process?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/50744/wait-until-file-is-unlocked-in-net">Wait until file is unlocked in .NET</a>  </p>
  </blockquote>
  
  
  
  <p>I have many cases where a program must wait until a file is unlocked by another process (e.g file being copied) before it can be used again. A standard solution is to wait for it iterating in a loop using Thread.Sleep(). I don't consider that kind nice. I've read it's possible to do it with the FileSystemWatcher of .NET (I'm using C#). Can anyone illustrate it? Thanks a lot for your replies!</p>