ASP Directory Listing
To access a folder, you first create a FileSystemObject then use the GetFolder() method specifying the physical path of that folder.
dim fso , folder , file
set fso = CreateObject(”scripting.FileSystemObject”)
set folder = fso.GetFolder(”D:\inetpub\publicstatic\test\UploadedFiles)
To find the path of a file on the local web site, the built-in Server.MapPath() function can be used to translate a URL to a physical path.
path = Server.MapPath(”/UploadedFiles/”)
Which might return “D:\Inetpub\publicstatic\test\UploadedFiles\” for example. This value can then be used in the GetFolder() call.
Among the Folder object’s properties are the Files and SubFolders collections. These can be enumerated to list the folder contents.
To following sample code will retrieve the list of files from the folder
For each file in folder.Files
Response.Write(file.Name)
Next
