5


In my project I need to watch multiple FTP Folders continuosly, if any new file comes i need pick the filename and do some process.

If that is normal Windows/Local File System folder I can achieve this by using SystemFileWatcher of .net.

Is there any thing like SystemFilewatcher to watch FTP folders?


nrk

nRk
  • 1,251
  • 7
  • 24
  • 50

2 Answers2

7

No this doesn't exist, because a FTP folder can't send you any events about any change. So you have to write your own little class with a background worker. This one asks the ftp server for directory listing periodically and compares it against the last list obtained. Then you can fire some events depending on the happen changes.

So you'll get an event class in .Net but under the hood it will be pull model with lot of traffic on the wire.

Oliver
  • 43,366
  • 8
  • 94
  • 151
0

I don't understand @Oliver's answer. Of course there is a way to use the FileSystemWatcher class to watch events in an FTP folder, and it's not a pull model. I'm working on creating something just like it right now, using the model as described in this MSDN article:

Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy

To effectively use the FSW, you build it into a Windows Service, and have it watch the FTP folder(s). Of course, you'd need to install it on the FTP server (not somewhere else in the network), but it would do exactly what you need.

Cyberherbalist
  • 12,061
  • 17
  • 83
  • 121
  • From what I gather, the question was about watching an FTP folder *remotely*, i.e. to do some kind of reverse synchronization. You are of course correct if the question was really about watching an FTP "dropoff" folder on a local server. – Aaronaught Apr 06 '10 at 00:37
  • @Cyberherbalist: Yes, if you are the server you can implement a FSW on this server (it's irrelevant who creates the file on which way on the server). But the question was how can a ftp client implement a FSW on a ftp server. And in that case you always have a pull model, cause the ftp protocol doesn't have any such mechanism specified. – Oliver Apr 06 '10 at 11:48