I want to download the oldest file from the directory on the FTP server.
I am connecting to the FTP server using FtpWebrequest
to get the list of files in the directory. I use WebRequestMethods.Ftp.ListDirectoryDetails
to do so. Once I know the file name, I'll create another FTP connection to download that file.
However, the details I get in the FtpWebResponse
stream are in different format when FTP is on Linux and when it's on the Windows.
- How to deal with this problem?
- I can write different methods for Linux and Windows that parse the response stream. But for that, at least the way Linux Ftp and Windows FTP provides details should be definite. Do you know if the way details are sent may vary from one Linux FTP server to another?
- I observed (at least on the Windows FTP) that the oldest file is listed at the end of the response stream every time. And the file name is at the end of every line. Can I take it for granted and write a code?
- Can you suggest smarter way of getting the oldest file details?