Owen Delahoy
Owen Delahoy

Reputation: 805

File Close Notification

I wish to know when another application finishes editing a file.

I am aware of FindFirstChangeNotification, ReadDirectoryChangesW and the FileSystemWatcher class, however I think these are only able to detect file creation and changes. Which won't allow me to know whether the file still has content which will be written to it in future or not. One solution would be to wait to ensure that all data has been written, but I feel that there should be a better way.

I wish to know when the process writing to the file closes the handle it has, I think writing a File System Filter Driver may allow for this, can anyone confirm? Or provide another method I which I could use. Also I would prefer not to rely on something like .net but I wouldn't rule it out.

Thanks very much, in advance.

Upvotes: 2

Views: 782

Answers (1)

rasmus
rasmus

Reputation: 3216

You can poll this by trying to open the file in exclusive mode.

On windows you can use OpenFile with OF_SHARE_EXCLUSIVE.

Upvotes: 3

Related Questions