I have list of files placed at SFTP server. I need my application to get the latest file placed. 2 files will be placed daily 3/8/2016 11:00PM 3/8/2016 2:00PM 3/7/2016 11:00PM 3/7/2016 2:00PM 3/6/2016 11:00PM 3/6/2016 2:00PM I need to sort and get the first one .Please help!!!
asked Mar 10 at 11:25
If you need to get only the latest file -- you don't need to sort. You simply need to make as single pass over the files in the SFtpDir object and keep the most recent one. In pseudo-code:
mostRecentFile = sftpDir.GetFileObject(0) numFiles = sftpDir.NumFilesAndDirs for i = 1 to numFiles-1 f = sftpDir.GetFileObject(i) if f is more recent than mostRecentFile then mostRecentFile = f next
Sorting is more work than you actually need to do...
answered Mar 10 at 17:35