EldoS | Feel safer!

Software components for data protection, secure storage and transfer

GetFileList returned TElFTPFileInfo.FileDate adds a year to server dat

Posted: 08/26/2014 15:16:03
by Ganapathi ekambaram (Standard support level)
Joined: 08/26/2014
Posts: 2

Below code returns datetime year value one year ahead of server filedate for oldest files in FTP server directory, datetime on server does not change but SecureClientBlack adds one year to actual filedate for oldest file on the folder n random basis , please let me know if you come across such a issue

ArrayList arrListOfFiles = new ArrayList();
Client.GetFileList(fileParam, arrListOfFiles);
            if (arrListOfFiles.Count > 0)
                for (int i = 0; i < arrListOfFiles.Count; i++)
                    SBSimpleFTPS.TElFTPFileInfo telFtpFile = (SBSimpleFTPS.TElFTPFileInfo)arrListOfFiles[i];
                    //ftpFile.FileDir = telFtpFile.Name.Substring(0, telFtpFile.Name.LastIndexOf("//"));
                    ftpFile.FileName = telFtpFile.Name;
                    ftpFile.FileSize = telFtpFile.Size;
                    ftpFile.FileTimeStamp = telFtpFile.FileDate;

Posted: 08/26/2014 15:22:44
by Eugene Mayevski (Team)

FTP has no predefined listing format. Many servers use Unix listing format, but as it's not standardized also, there can be certain problems. In particular, there's a common rule to omit year but write time instead for files which are less than X old. And here the problem happens - on some Unix/Linux systems this X is 183 days before and 182 days after today (variant A), while for other systems this X is 365 days before today (variant B). Our code assumes the remote system is Linux (as more popular) and Linux uses variant A. If your server uses variant B, then files created 183 < T < 365 days ago will have the year incorrect.

The solutions are (a) use MLSD command if it's supported by the server, and (b) manually adjust a year if it's in future but less than 183 days in future.

On a side note please use CODE button to mark the beginning and the end of the code block in your messages.

Sincerely yours
Eugene Mayevski
Posted: 08/26/2014 15:52:17
by Ganapathi ekambaram (Standard support level)
Joined: 08/26/2014
Posts: 2

Thank you very much for your reply...

For option b
b)Manually adjust a year if it's in future but less than 183 days in future.

Can you post or send an email of logic to handle all OS types and all variants for production level code...
Posted: 08/26/2014 16:03:03
by Eugene Mayevski (Team)

This is not possible. If you re-read what I wrote above, FTP doesn't have a standard format for FTP listings. The extension of FTP specification for a standard format is MLSD command and you should use it if this command is supported by the server. Otherwise there can be no universal solution.

Sincerely yours
Eugene Mayevski



Topic viewed 529 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!