title: C# - Detect locked files in a directory
body: <p>I am looking for a way to watch a directory (and its sub-directories) for locked files i.e. when an application opens a file and locks it, an event should trigger in my app.</p>
  <p>So far I have been using FileSystemWatcher for other purposes like detecting rename, update, etc. But watching lock [using last access] requires a registry tweak as specified <a href="http://social.msdn.microsoft.com/Forums/vstudio/en-US/5752e234-6429-456c-bbd0-a2bbf49c5914/filesystemwatcherchanged-event-does-it-fire-when-a-file-is-accessed?forum=netfxbcl" rel="nofollow noreferrer">Here</a>
  which is not an option so far.</p>
  <p>Other solution that I have thought so far is continuously look for change in 'LastAccess' attribute using FileInfo object from another thread and verify if the file is locked.</p>
  <p>Is there a better solution?</p>