Search code examples
c#.netftpftpwebrequest

C# class to parse WebRequestMethods.Ftp.ListDirectoryDetails FTP response


I'm creating a service to monitor FTP locations for new updates and require the ability to parse the response returned from a FtpWebRequest response using the WebRequestMethods.Ftp.ListDirectoryDetails method. It would be fairly easy if all responses followed the same format, but different FTP server software provide different response formats.

For example one might return:

08-10-11  12:02PM       <DIR>          Version2
06-25-09  02:41PM            144700153 image34.gif
06-25-09  02:51PM            144700153 updates.txt
11-04-10  02:45PM            144700214 digger.tif

And another server might return:

d--x--x--x    2 ftp      ftp          4096 Mar 07  2002 bin
-rw-r--r--    1 ftp      ftp        659450 Jun 15 05:07 TEST.TXT
-rw-r--r--    1 ftp      ftp      101786380 Sep 08  2008 TEST03-05.TXT
drwxrwxr-x    2 ftp      ftp          4096 May 06 12:24 dropoff

And other differences have been observed also so there's likely to be a number of subtle differences I haven't encountered yet.

Does anyone know of a fully managed (doesn't require access to external dll on Windows) C# class that handles these situations seamlessly?

I only need to list the contents of a directory with the following details: File/directory name, last updated or created timestamp, file/directory name.

Thanks in advance for any suggestions, Gavin


Solution

  • One solution I came across is EdtFTPnet

    EdtFTPnet seems to be quite a feature packed solution that handles lots of different FTP options so is ideal.

    It's the free open source solution that I've how employed for http://www.ftp2rss.com (a little tool I needed myself but figured might be useful to others also).