Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

work backwards through files in Folders object

Status
Not open for further replies.

jender624

Programmer
Jul 1, 2003
50
US
Hi all,

There is a folder on our network drive that I'm reading into a Folders object (through the use of a FileSystemObject). There are 5000 files in the folder, and I'm only looking for the latest set of them based on the date created/modified property of the file, which is how the folder will always be sorted (ascending). Thus, the set of files I'm looking for are always at the end of the list.

Instead of looping through all files in the folder to get what I want (currently takes 5 or so minutes), is there a way of working backwards from the end of the file list to the beginning, so I can stop when I've got what I want? This would eliminate the pain of waiting............................

Thanks!

jender624
 
Set Files = Folder.Files
For lngCnt = Files.Count to 0
Files(lngCnt)...
Next lngCnt
 
Set Files = Folder.Files
For lngCnt = Files.Count to 0 Step -1
Files(lngCnt)...
Next lngCnt

to be precise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top