Home Forums .NET libraries Xceed SFTP/FTP for .NET Error after entering the year 2009: "Year, Month, and Day parameters describe an un-representable DateTime"

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21112 |

    This error occurs when using the GetFolderContents method. This error only happpends for some of our regular FTP download sites. I’ve seen several other posts on different forums related to other components/products – same error. Happens after 01.01.2009.

    Plz help! Our production systems are hit hard by this error as we have to download files from 30 sites manually on a daily basis.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Per (had 6428 views)

    User (Old forums)
    Member
    Post count: 23064

    And this is the full stack trace:

       StackTrace ”   at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day)\r\n   at System.DateTime..ctor(Int32 year, Int32 month, Int32 day)\r\n   at Xceed.Ftp.FtpUnixListingParser.ParseLine(String line)\r\n   at Xceed.Ftp.FtpListingParserList.ParserSelector.ParseLine(String line)\r\n   at Xceed.Ftp.FtpListingParserList.ParseListing(StringList lines)\r\n   at Xceed.Ftp.Engine.ListFtpCommandSequence.OnCommandCompleted(BaseFtpCommand command, FtpReply reply)\r\n   at Xceed.Ftp.Engine.FtpCommandSequence.CommandCompleted(IAsyncResult asyncResult)” string

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Per (had 504 views)

    User (Old forums)
    Member
    Post count: 23064

    We just started getting this error on our production machine as well. We are using quite an old version of the Ftp object so I’m wondering if this has been fixed in later iterations. Our verison is 1.0.105.0. The behavior sounds about the same it occurs on GetFolderContents and just started happening after the first of the year. The server we are connecting to in this case is GlobalScape but it doesn’t seem to be completely related to the files in 2009. We have files in this folder from 2007 through 2009. If I remove all the files then there is no error, if I remove all but the 2009’s then I get no error. I’d added in random files to see if I could get the error but haven’t found the right file yet. If I put them all in there then the issues shows itself.

    Nathan

     

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Nathan (had 783 views)

    User (Old forums)
    Member
    Post count: 23064

    Indeed we have the same error as well since 1/1/2009. (version 1.1.5181.0)

    No sultion yet ?

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Xavier (had 601 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

      Would it be possible to get the type of server on which you get this error?

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Chris [Xceed] (had 551 views)

    User (Old forums)
    Member
    Post count: 23064

    I have connected manually and have been able to find the FTP server type from 3 of our 4 failing FTP download sites:

     1. SlimFTPd 3.18, by WhitSoft Development (www.whitsoftdev.com)

    2. ProFTPD 1.3.0 Server (Unix)

    3. ProFTPD 1.2.7 Server (Unix 

    3. Unsure, but its a Unix box: 

    [22:03:15] SYST

    [22:03:15] 215 UNIX Type: L8

    [22:03:15] Detected Server Type: UNIX 

    )

    We also used an old version of Xceed FTP, but I tried out the trial version on the newest version. Same problem for both versions. 

    If you guys (Xceed) solve this issue quick, I will upgrade my whole Xceed suite ASAP!

    Thanks! 

      

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Per (had 635 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Per,

      would it be possible to get a test access to one of the problematic server to help us identify where the problem could be? If so, just send an email at support@xceed.com at Chris’ attention refering this forum post. 

    Thanks, your help is really appreciated !

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Chris [Xceed] (had 510 views)

    User (Old forums)
    Member
    Post count: 23064

    We have finally identified the issue.  What happens is that some servers don’t not return the full date for files created less than one year ago. That is, they will only return the day/month part of the date, not the year.  So when parsing the file listing, the library assumes that when the year is not provided, it is the current year.  In this case, the library always set the year to 2009 (which may not be right, since it could be 2008).  Now, 2008 was a leap year (February 29), which is not the case for 2009.  Thus, when the library sets the date to February 29, 2009, System.DateTime does not recognize it as a valid date, thus the exception.

    We have corrected the library so that the year the library now sets is valid (e.g. February 29, 2008) for all files, and it now works fine.  The fix will be available sometime in February 2009, and it will be in version 4.0.  Note that .NET 2.0 is required to run this version.

    Meanwhile, the workaround is to provide your own parser in the case of problematic dates.  Here is a way to do it, but you will need to add your own parsing algorithm. 

     

    First, provide the custom parser :

     

    public class CustomUnixListingParser : FtpUnixListingParser

    {

        public override FtpItemInfo ParseLine( string line )

        {

            FtpItemInfo itemInfo = null;

            try

            {

                itemInfo = base.ParseLine( line );

            }

            catch( Exception )

            {

                // Create an empty FtpItemInfo to populate with the relevant information

                itemInfo =

    FtpItemInfo.Empty;

                //Parse the line manually for problematic files here

            }

            return itemInfo;

        }

    }

     

    Then use it this way in the client code :

     

    FtpClient ftpClient = new FtpClient();

    // Lookup for the FtpUnixListingParser

    int unixParserIndex = 0;

    foreach( FtpListingParser parser in ftpClient.ListingParsers )

    {

        if( parser is FtpUnixListingParser )

        {

            break;

        }

        unixParserIndex++;

    }

    // Replace the default FtpUnixListingParser by the custom one

    ftpClient.ListingParsers[ unixParserIndex ] =

    new CustomUnixListingParser();

    //Get the listing, which will call the custom code for a Unix format

    itemList = ftpClient.GetFolderContents();

     

    Now, if your server uses another format, you may have to derive from a different parser, or if you connect to different servers which are using different listing format, you will have to implement more than one parser.  You will find the default ones we support here :

    http://doc.xceedsoft.com/products/XceedFileSystem/Xceed.Ftp~Xceed.Ftp.FtpListingParser.html

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 5624 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.