如何通过c#监视FTP文件 [英] How to Monitor FTP files by c#

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

问题描述

我只想知道FTP站点中是否有任何新文件,并且如果在FTP站点中有新文件上传,那么我会将这个文件下载到本地系统.有人可以给我一些建议吗?

I just want to know there whether are any new files in the FTP site, and if a new file be uploaded in the FTP site, then I will download this file to local system. Could someone give me some suggestions?

推荐答案

也许是FileSystemWatcher?
http://msdn.microsoft.com/en-us/library/system.io. filesystemwatcher.aspx [ ^ ]
a FileSystemWatcher maybe?
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^]


这只是与SAKryukovs的出色答案有关的一些额外信息.
FileSystemWatcher有一些约翰·西蒙斯在以下文章中发现的怪癖:
FileSystemWatcher-纯混沌(第1部分,共2部分) [ ^ ]
FileSystemWatcher-纯混沌(第2部分,共2部分) [ ^ ]

最好的问候
Espen Harlinn
This is just some extra info related to SAKryukovs'' excellent answer.
FileSystemWatcher has some quirks that John Simmons uncovers in the following articles:
FileSystemWatcher - Pure Chaos (Part 1 of 2)[^]
FileSystemWatcher - Pure Chaos (Part 2 of 2)[^]

Best regards
Espen Harlinn


请参阅解决方案1 ​​和我对此的评论.你是对的,你做不到. FTP并非设计成使之成为可能的方式.因此,只有在托管有问题的文件的计算机上使用其他服务时,您才能执行此操作.

如果是Windows操作系统,则可以开发一些通过订阅运行的Windows服务.如果服务的客户端通过连接到服务器来订阅,则它还可以将数据传递到文件系统的哪个部分.在内部,服务应使用FileSystemWatcher并本身订阅所需的事件.

请查看我过去的回答以了解此类服务:
来自同一端口号的多个客户端 [ http://msdn.microsoft.com/en-us/library/d56de412%28v = vs.100%29.aspx [ ^ ].

—SA
Please see Solution 1 and my comment to it. You are right, you cannot do it. FTP is not designed the way to make it possible. Therefore, you can do it only if you use yet another service on your computer hosting the file in question.

If this is Windows OS, you can develop some Windows Service working by subscription. If a client of the service is subscribed by connection to the server, it can also pass the data on what part of file system. Internally, the service should use FileSystemWatcher and itself subscribe to the required events.

Please see my past answer to get an idea of such service:
Multple clients from same port Number[^].

For development of Windows Services, please start here:
http://msdn.microsoft.com/en-us/library/d56de412%28v=vs.100%29.aspx[^].

—SA


这篇关于如何通过c#监视FTP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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