
August 16th, 2005, 09:52 AM
|
 |
Newton's Apple Wizard
|
|
Join Date: Nov 2003
Location: Los Angeles
|
|
|
List Contents of a Directory
If you want to list the contents of a directory on the server, use the following code:
ASP Code:
Original
- ASP 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." _ & "</li>" & 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, " _ & "last modified on " & item.DateLastModified & "." _ & "</li>" & vbCrLf) next Response.Write("</ul>" & vbCrLf) end sub %>
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.
|