问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/20975109/ftp-details-command-doesnt-seem-to-return-the-year-the-file-was-modified-is-th