Getting Accurate Last-Modified File Times from an FTP Server

Question:

We have the need to get the file time properties of files located on a ftp site.  Currently when I call GetCreateTime, GetLastAccessTime or GetLastModifiedTime I only get the hour and minute of the file (and all three methods return the same value).  I also need to get the Seconds in addition to the hour and minute.  How is it possible to do this?

Answer:

The seconds may or may not be available, depending on your FTP server.  If your server supports the MLSD, then Chilkat FTP2 will automatically use it (assuming you’re using a version of FTP2 that’s not too old).  The MLSD command should provide accurate information.  If MLSD is not available, then the FTP2 component must parse the human-readable directory listing that comes back from the FTP server — and in most cases the Seconds part of the time is not available for files that are too old.

If you’re curious, check the SessionLog property to see what the FTP server is sending.  (Be sure to turn on the KeepSessionLog property beforehand.)

Tags :