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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display records in descending order

Status
Not open for further replies.

Ken011

MIS
Oct 13, 2006
66
US
Greetings (again) all.

The code below displays records saved to various folders.

It works fine except that records are sorted alphabethically by default.

Is there anyway to sort the records by date in descending order:

Thanks in advance.

Code:
<% sub ListFolderContents(path)

     dim fs, folder, file, item, url

     set fs = CreateObject("Scripting.FileSystemObject")
     set folder = fs.GetFolder(path)

    'Display the target folder and info.

     Response.Write("<li><b>" & folder.Name & "</b> - " _
       & folder.Files.Count & " files, ")
     if folder.SubFolders.Count > 0 then
       Response.Write(folder.SubFolders.Count & " directories, ")
     end if
     Response.Write(Round(folder.Size / 1024) & " KB total." _
       & vbCrLf)

     Response.Write("<ul>" & vbCrLf)

     'Display a list of sub folders.

     for each item in folder.SubFolders
       ListFolderContents(item.Path)
     next

     'Display a list of files.

     for each item in folder.Files
       url = MapURL(item.path)
       Response.Write("<li><a href=""" & url & """>" & item.Name & "</a> - " _
         & item.Size & " bytes, " _
         & "Posted on " & item.DateLastModified & "." _
         & "</li>" & vbCrLf)
     next

     Response.Write("</ul>" & vbCrLf)

     Response.Write("</li>" & vbCrLf)

   end sub

   function MapURL(path)

     dim rootPath, url

     'Convert a physical file path to a URL for hypertext links.

     rootPath = Server.MapPath("/")
     url = Right(path, Len(path) - Len(rootPath))
     MapURL = Replace(url, "\", "/")

   end function
   %>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top