Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

how to sort filenames

i want to sort the files in a folder by date & time. any way?
0
ackid32
Asked:
ackid32
1 Solution
 
rdrunnerCommented:
There is a great tool for all yout sorting needs...

Its called a Recordset... Just fill in all data about the files you have and sort by the fields you want by just telling which fields you want...

This example only cares about name & Date

'snipp

Dim oRS As New Recordset
oRS.Fields.Append "name", adVarChar, 255
oRS.Fields.Append "date", adDate

Set oFolder = ofso.GetFolder("c:\winnt")
oRS.Open
For Each oFile In oFolder.Files
        oRS.AddNew
        oRS("name").Value = oFile.Name
        oRS("date").Value = oFile.DateLastModified
Next
oRS.Sort = "date asc"
oRS.MoveFirst

While Not oRS.EOF
    Debug.Print oRS("name"), oRS("date")
    oRS.MoveNext
Wend

'snapp

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now