Reputation: 4327
I"m looking for something (Win API calls or whatever) to notify me when a file becomes available for editing (i.e. no longer in use). Should I set up a timer to check the files on some interval or is there a good way to set up a watch on the file?
Upvotes: 2
Views: 1977
Reputation: 124776
FileSystemWatcher doesn't help, nor does the Win32 FindFirstChangeNotification: they won't tell you when someone releases a file handle.
Your best way is to periodically attempt to open the file with the access you want, handling any errors.
Even if you were notified that a file was available, that won't guarantee that it will still be available when you subsequently try to open it.
Upvotes: 2
Reputation: 89232
I don't know what .NET's System.IO.FileSystemWatcher does, but if you could use that, you could get events when things about a file changes.
Upvotes: 1