1

I have a program that needs to download a file from ftp with the latest modified date.

I have the usual code to connect and I use this method.

request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

The data that comes back looks like:

-rw-r--r--  1 myftp  cats  1691090 Jan  6 20:52 somefile.zip

There is no year component here so I can't use this date for comparison because it'll fail once we get to December and it rolls around to january.

Any ideas? The FTP server is a 3rd party so I can't make any changes to it.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
NibblyPig
  • 51,118
  • 72
  • 200
  • 356
  • See [List only files and Last Modify Date of a FTP server with C#](http://stackoverflow.com/questions/1408211/): _"FTP list results are non-standard so every FTP server could potentially return something different"_. Did you try searching for a thrid-party library that has this parsing built in? See also [Retrieving creation date of file (FTP)](http://stackoverflow.com/questions/4454281/retrieving-creation-date-of-file-ftp) -> [System.Net.FtpWebRequest GetDateTimestamp example](http://stackoverflow.com/questions/1040371/system-net-ftpwebrequest-getdatetimestamp-example). – CodeCaster Jan 07 '14 at 15:16
  • I see, thanks. Will figure out a workaround. – NibblyPig Jan 07 '14 at 16:01
  • Does the server support the [MDTM](http://tools.ietf.org/search/rfc3659#section-3) FTP command? – Andrew Lambert Jan 07 '14 at 19:09

1 Answers1

3

These example appears to be following the same standard as the UNIXy ls -l command, which only shows the year for dates older than six months.

If that's the case, you could infer the year easily but you should be aware that the format isn't guaranteed, it probably depends on the underlying OS the FTP server is running on.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • This helped a lot. It looks like it will only return the year if it is older than 6 months old or else it returns the time in `%H:%M` format. A workaround I did was to check for that colon before parsing. – A Simple Programmer Jul 13 '22 at 21:59