Question

I'm working on a very basic scheduled FTP program, but I don't want to bother transferring files if the Last Modified date hasn't changed, so I need to compare the last stored modified time with the current modified time pre-download. I'm using FtpWebRequest/FtpWebResponse to set up the connection.

Is there any way to use IO.FileInfo with an FTP? If not, is there a class that will let me get the modified date?

Thanks

Was it helpful?

Solution

You'll need to request a directory listing from the server and then parse it to find the date on each file... then compare it to the dates on your local files. Even though FTP is a "standard" it does not specify the directory listing format so naturally each vendor has their own style which can be a pain in the rear of you are planning to connect to multiple sites.

It might be a better use of your time to use a scriptable FTP client like Robo-FTP that also supports a COM interface. The script for downloading only new or updated files once per day:

:top
CRON "@daily"
WORKINGDIR "c:\local\download\folder"
FTPLOGON "ftp.mydomain.com" /user="userID" /pw="secret"
RCVFILE "*" /ifnewer
FTPLOGOFF
GOTO top

You'll notice it is an infinate loop with one iteration per day. You set this up to run as a Windows Service so it starts automatically whenever the computer is rebooted and thats it, you are done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top