C# FileSystemWatcher And FTP

后端 未结 6 1302
南旧
南旧 2021-02-02 03:48

I monitor files that are dropped on a ftp via filesystem watcher then move to another dir. Now I trigger the copy off the create event of the filesystem watcher but obviously i

6条回答
  •  北海茫月
    2021-02-02 03:55

    Have the source upload a stub file directly after the data file completes, and have your FileSystemWatcher watch for the stub file. For example, if the data file name is mydata_01234 then the stub woulb be mydata_01234_stub. The FileSystemWatcher should then have a mask of "*_stub". You then know the data file name by stripping off the "_stub" suffix. And the stub file cannot be uploaded until after the data file completes, so the data file will be free.

    If the stub files are just one byte each you should be able to remove them after whatever operation you're performing with the data file without issue. If your operations are particularly fast, add a 100 ms sleep before deleting the stub.

提交回复
热议问题