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.
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 Here which is not an option so far.
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.
Is there a better solution?