Question

I have a Windows process that runs in the background and periodically backs up files. The backup is done by uploading the file to a server.

During the backup, I don't want to lock any other application out of writing to or reading from the file; if another applications wants to change the file, I should stop the upload and close the file.

Share mode is useless here; even though I'm sharing all access to the file being read, if the other process attempts to open it for writing without sharing read, it will be locked out of the file.

Is it possible to accomplish this on Windows, without writing a driver?

Was it helpful?

Solution

You may be interested in Volume Shadow Copy.

OTHER TIPS

You certainly could copy the file and then check that the original and copy are identical (thus representing a consistent snapshot) prior to uploading to the server.

According to this MSDN page, if using NTFS, you should be able to lock the file inside a transaction of yours, while uploading the file to a server. This will ensure your view of the file does not change, even if the file has been changed externally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top