Announcement

Collapse
No announcement yet.

asp-VBS help: Showing list of files sorted

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    asp-VBS help: Showing list of files sorted

    Hi all,

    I have succeded an asp page that shows a list of files of a certain directory, using this code found on a site somewhere:

    set fs = createObject("scripting.filesystemobject")
    set root = fs.getFolder(ReqDir)
    Set colFiles = root.Files
    For Each objFile in colFiles
    Set f = fs.GetFile(objFile)
    ShowFileInfo = f.DateCreated
    response.write "&ShowFileInfo&"</b></a> "

    It seems that files are sorted by name, and I wish to have them by date, reverse order...

    Hope someone can help
    Thanks
    Visit zee e-maison : http://www.e-maison.com

    #2
    This should be close. It uses the recordset object to perorm a sort and puts the path and created date into the recordset to be sorted.

    Code:
    Const adDate = 7
    Const adVarWChar = 202
    set fs = createObject("scripting.filesystemobject")
    set root = fs.getFolder(ReqDir)
    Set colFiles = root.Files
    With CreateObject("adodb.recordset")
        .Append "Name", adVarWChar, 255
        .Append "Create", adDate
        .open
        For Each objFile in colFiles 
            Set f = fs.GetFile(objFile) 
            .add f.DateCreated
            .add f.path & "\" & f.name
            .update 
        Next
        .sort = "Create"
        do until .eof
            response.write .Fields("Name") & vbTab & .Fields("Create")
            .movenext
        loop
    end with

    Comment


      #3
      Visit zee e-maison : http://www.e-maison.com

      Comment

      Working...
      X