We search a reliable possibility to get notified when a file was modified by another application.
The .NET FileSystemWatcher class and the ReadDirectoryChangesW() function both suffer from the problem that they generate the event even if the other application has not finished writing yet.
Under Linux, inotify provides an IN_CLOSE_WRITE event - the file was closed after being opened for writing.
Is there any way to get that information on windows?
[Edit for clarification:] I'm primarily interested in when the writer finished its work, not about exclusive access / locking isuses. And I want to avoid polling / repeated try-and-catch-exception like solutions, as those are generally a bad programming style, and event based programming is better for power saving.
Thanks, Markus