FileSystemWatcher - is File ready to use

后端 未结 6 1100
[愿得一人]
[愿得一人] 2020-12-03 17:45

When a file is being copied to the file watcher folder, how can I identify whether the file is completely copied and ready to use? Because I am getting multiple events duri

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 18:29

    I had this problem when writing a file. I got events before the file was fully written and closed.

    The solution is to use a temporary filename and rename the file once finished. Then watch for the file rename event instead of file creation or change event.

提交回复
热议问题