How to know a file is finished copying

前端 未结 3 620
小鲜肉
小鲜肉 2021-01-22 07:28

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 writ

3条回答
  •  天涯浪人
    2021-01-22 07:43

    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.

    EDIT: This is not the optimal solution in the average case, but consider that in the OP's case better solutions are ruled out by the problem constraints. Think about this before you think of downvoting.

提交回复
热议问题