views:

392

answers:

1

I’m using ReadDirectoryChangesW to spy a folder, if I’m copying a large file to the folder, I can receive multiple FILE_ACTION_MODIFIED messages, it seems each time windows writes a large chunk of the file, you get the file modified notification for each time. I tried to use CreateFile API to check if the file can open by AP or not, but sometime, some of files are always locked by other AP, for example, if you are opening the Outlook, the PST will update, but my AP can’t access it, we have to start Shadow Copy to open it. So my question is, how to know a file is finished copying?

+1  A: 

This is a solution of a very hacky nature, but in a very hairy situation you can run a polling loop to check the size (or modified date) of the file. If it doesn't change for a while, you can somewhat safely assume that the file is finished copying.

Fritz H