如何监视FTP文件夹以进行新文件上载 [英] How can I monitor FTP folder for new file upload

查看:136
本文介绍了如何监视FTP文件夹以进行新文件上载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 FileSystemWatcher 来观看FTP位置。到达新文件时,将触发创建的事件,并在上载文件时触发更改事件。现在,问题是从任何客户端应用程序上传文件,然后用户可以暂停 - 恢复或中止上传,然后触发更改事件。此外,当上传文件暂停几秒钟并恢复时,再次成功上传时会触发Changed事件。



在这种情况下,我如何识别,文件是否是经过多次暂停/恢复或取消后完全上传?

I am using FileSystemWatcher to watch FTP location. When new file is arrived, created event is fired,and when file is uploaded, change event is fired. Now, problem is when file is uploaded from any client application, then an user may pause-resume or abort uploading, then also Change event is triggered. Also, when uploading file is paused for few seconds and resumed, again Changed event is triggered on successfully upload.

In this scenario, how I can identify, whether file is completely uploaded, after many pause/resume or cancellation?

推荐答案

FileSystemWatcher不值得信任。





而不是FileSystemWatcher你可以使用计时器。

设置一个计时器并在特定时间间隔内查看文件夹,当你看到一个新文件时进行操作。



FileSystemWatcher失败时的情况:

1.当您使用网络驱动器进行存储时。

2.有时它将吃掉通知,不会通知。
FileSystemWatcher is not trust worthy.


Instead of FileSystemWatcher you can go with timer.
Set a timer and look inside the folder after particular interval, when you see a new file do the operation.

Situations when FileSystemWatcher will fail:
1. When you are using Network drives for storage.
2. Sometimes it will eat out the notification and will not notify.


这篇关于如何监视FTP文件夹以进行新文件上载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆