Search code examples
c#ftpfile-listing

How to read the creation date from a string[] with FTP ListDirectoryDetails?


I have a windows service that connects to a FTP server and lists a directory with details. Based on the creation date of the files I am going to download them(I already have the code for the download). I have the function that returns a string[] in the following format:

09-30-14 01:52PM 9392 test.xlsx

From what I understood, they could be displayed in a different format like the one posted here: Parsing FtpWebRequest ListDirectoryDetails line which is something like that:

-rw-r--r-- 1 ftp ftp 659450 Jun 15 05:07 TEST.TXT

The first thing is, how do I deal with different formats?

And the second is, how can I select only files created after a specific time (for example after 09-30-14 01:50PM) ?


Solution

  • Not really an answer to the question, but at first I ended up with making a separate call to the FTP server to get the LastModified datetime of the file(not a good solution) and added them to a list of file names with creation dates. In the end it turned out that the creation date of the file is no longer important for the project, so I just used the standard FTP ListDirectory.