Bugfix in Date found: Please use DateTimeStyles

Apr 8, 2016 at 3:19 PM
Edited Apr 8, 2016 at 6:55 PM
Call it feature or Bugfix. If FTP server does respond with local time, not UTC, it can occur that the very wrong time is read of any file.
            if (DateTime.TryParseExact(m.Groups["modify"].Value, datefmt, CultureInfo.InvariantCulture, FtpClient.DateTimeOnFtp, out modify))


            if (DateTime.TryParseExact(m.Groups["modify"].Value, datefmt, CultureInfo.InvariantCulture, FtpClient.DateTimeOnFtp, out modify))


            item.Modified = m.Groups["modify"].Value.GetFtpDate(FtpClient.DateTimeOnFtp);


            if (!DateTime.TryParse(m.Groups["modify"].Value, CultureInfo.InvariantCulture, FtpClient.DateTimeOnFtp, out item.m_modified))

I just replaced Assumelocal to fix the datetime issue of UTC.

used in FTPBox:
http://goldengel.ch/shop/ProductView/index.aspx?sku=21
    private static DateTimeStyles _DateTimeOnFtp = DateTimeStyles.AssumeUniversal;
    /// <summary>
    /// Setup the FTP time on elements. This is setup on Server.
    /// </summary>
    public static DateTimeStyles DateTimeOnFtp
    {
        get
        {
            return _DateTimeOnFtp;
        }
        set
        {
            _DateTimeOnFtp = value;
        }
    }