1

I am developing an application for downloading file from FTP servers. The FTP servers are updated and different datetime formats, I receive. And I cannot parse them. How can I find the different results format of FTP's? Is there a sit or a general solution for different formats? For example, I received from different servers these formats:

1- 08-31-16  10:41PM                   95 Global.asax
2- -rw-r--r--    1 0        0          239832 Apr 01  2014 DriverPackSolution.exe

Thanks for your help.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user2352554
  • 521
  • 4
  • 17

1 Answers1

2

There's no standard or general solution for formats of the listing response to the FTP LIST command. The LIST command is what is behind the ListDirectoryDetails method of the FtpWebRequest.

The LIST command was introduced at times, when machine parsing was probably not expected (early 1980's).

To overcome this problem the MLSD command was introduced later. Format of a listing for this command is defined by the RFC 3659. An official example:

Type=cdir;Modify=19981107085215;Perm=el; tmp
Type=cdir;Modify=19981107085215;Perm=el; /tmp
Type=pdir;Modify=19990112030508;Perm=el; ..
Type=file;Size=25730;Modify=19940728095854;Perm=; capmux.tar.z
Type=file;Size=1830;Modify=19940916055648;Perm=r; hatch.c
Type=file;Size=25624;Modify=19951003165342;Perm=r; MacIP-02.txt
Type=file;Size=2154;Modify=19950501105033;Perm=r; uar.netbsd.patch
Type=file;Size=54757;Modify=19951105101754;Perm=r; iptnnladev.1.0.sit.hqx
Type=file;Size=226546;Modify=19970515023901;Perm=r; melbcs.tif
Type=file;Size=12927;Modify=19961025135602;Perm=r; tardis.1.6.sit.hqx
Type=file;Size=17867;Modify=19961025135602;Perm=r; timelord.1.4.sit.hqx
Type=file;Size=224907;Modify=19980615100045;Perm=r; uar.1.2.3.sit.hqx
Type=file;Size=1024990;Modify=19980130010322;Perm=r; cap60.pl198.tar.gz

Unfortunately the .NET framework does not support the MLSD command.

You have to use a 3rd party FTP client library/assembly to take advantage of the standardized MLSD command.

See also

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992