I have the following problem:
We have to write an application that acts on changes on files. For example editing a word - file.
We achieve this using the FileSystemWatcher from .NET 2.0. When the word-file is saved the events correctly trigger, but the files are locked, which causes our action to fail, but this is not the problem. But when the user closes the word-application. The application release the lock,but we can't seem to catch this event so we could run our actions then.
Does anybody has as solution
Thx,
gert

Detecting remove lock event on file
Leonid Niraev
Lord Zoltan
rcreg
The problem here is that we have a 3,5 Terra drive full of files that multiple users can edit. If we start a thread that listens for every file that is locked i would have a lot of threads.
I'm searching for something that triggers if a file lock is released.
DRDRAIN
if (!IsFileLocked(path)) OpenFile(path, lockit);
There's an implicit and unavoidable race condition present in this statement. The file might well be locked by another thread between the IsFileLocked() call and the OpenFile() call. Modern multithreaded operating systems cannot make this work reliably. The only reliable approach is to try to take the lock and be notified when it failed. Windows does this.
enric vives
So if there is no explicit windows way to detect a lock, we are back to an old-school trial and error approach to find out whether there is a lock on a certain document
This seams a bit harsh in a otherwise feature rich environment, certainly because locks are something that has been along for so long.