Sort list of files in directory

J

Jean-Paul Lauque

Hello,

I'm beginning in the ASP world...

I would like to sort (descending) list of files in directory.

Parameter is directory url.

How I can to do that with ASP not ASP.NET.

Thank you very much.

Jean-Paul
 
J

Jeff Cochran

Hello,

I'm beginning in the ASP world...

I would like to sort (descending) list of files in directory.

Parameter is directory url.

Use the File System Object to retrieve the files collection.
Something like:

==============
' Get the folder needed from a query string
' could be Request.Form or whatever

Folder = Request.QueryString("Folder")

' Use the FSO to get the files collection

Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set DisplayFolder = FileSystem.GetFolder(server.mappath(Folder))
Set DisplayFiles = DisplayFolder.Files

' Display each file on a line in a web page

For Each FileName in Files
response.write FileName.Name & "<br>" & VbCrLf
Next
==============

The files are already sorted descending order, but you could load them
into an array and sort to your heart's content if you wish.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top