Unable to parse the directory list: String was not recognized as a valid DateTime.


I've been testing the AlexFTPS component to do some automated FTP directory synchronization and I wanted something that would support FTPS as well as plain FTP. My initial tests were against a Filezilla server over FTPS and everything works beautifully. However, my other test server is a Microsoft FTP server (version unknown) using standard FTP.
When I issue a GetDirectoryList() against the appropriate directory, I'm getting an AlexPilotti.FTPS.Common.FTPException with the message "Unable to parse the directory list." with an inner exception of System.FormatException with a message "String was not recognized as a valid DateTime.
I executed a GetDirectoryListUnparsed() against both servers and compared the date/time strings. The difference is subtle but the Filezilla server returns a date as Feb 08 05:19 and the Microsoft server is returning Feb 8 5:19. Using Reflector and stepping through code, I see the issue is the extra space between the 8 and the 5. A zero is added in front of the 8 in place of the space but the space in front of the 5 remains and when DateTime.ParseExact is executed with a format of "MMM dd HH:mm", the exception is thrown.
I just wanted to document this minor issue. I've attached a text file containing the unparsed directory list with an example of the offending date.
For now, I can use GetDirectoryListUnparsed() and write a parsing routine specifically for this server.

file attachments


alexp wrote Mar 3, 2011 at 5:22 PM

Hi, thanks for the feedback.
I'll provide a patch soon.

wrote Mar 3, 2011 at 7:25 PM

Pyroa wrote Dec 15, 2011 at 1:10 PM

I've got the same problem.
I found the solution, the problem is located in the function "ParseDirectoryListItemFromUnixStyleRecord" of the class "DirectoryListParser"

You have to change "dateFormat = "MMM dd yyyy" by "dateFormat = "MMM dd yyyy" (one space removed between dd and yyyy)

Hamaze wrote Dec 27, 2011 at 7:14 PM

Any update with this? I'm getting the same error. Thanks!

wrote Dec 27, 2011 at 7:14 PM

alexp wrote Jan 12, 2012 at 1:56 PM


I committed a solution in the sources. Let me know if it works for you.


wrote Feb 28, 2012 at 5:37 AM

wrote Feb 28, 2012 at 5:40 AM

rpurr wrote Feb 28, 2012 at 5:40 AM

Hi Alex,

we got the same error on IIS7.5, W2K8R2 Standard, Unix style, Culture en-US and de-DE.

According to .NET documentation, one may use H or H% instead of HH if the leading zero the hour is missing. I've attached a diff file for this problem.

This is tested with IIS7.5 only.


alexp wrote Feb 29, 2012 at 4:30 PM

Hi rpurr,

tx for the patch! did u check the latest version in the sources before providing the patch?
Let me know if you need a compiled copy.



rpurr wrote Mar 1, 2012 at 11:11 AM

Hi alexp,

I've checked out revision 71838 and applied my change there :-)
No need for a compiled version, we did this without any problem.


alexp wrote Apr 12, 2012 at 9:33 AM

Hi guys, here's the binary including rfuller's patch. Can you please test it in your scenario before I upload it to the Downloads section?




AimOrchard wrote Jul 16, 2012 at 12:43 PM

When are tickets marked as 'Fixed' here? :)

wrote Jul 17, 2012 at 5:53 PM

wrote Feb 21, 2013 at 11:35 PM

wrote May 16, 2013 at 11:06 AM

wrote May 16, 2013 at 11:06 AM

wrote Jun 14, 2013 at 7:27 AM