login about faq

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

learn's gravatar image

learn
1


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...

link

answered Mar 10 at 17:35

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×19
×2

Asked: Mar 10 at 11:25

Seen: 524 times

Last updated: Mar 10 at 17:35

powered by OSQA