%@ LANGUAGE="VBScript" %>
<% '***************************************************************************
'* ASP Directory Listing *
'* *
'* Do not remove this notice. *
'* *
'* Copyright 1999, 2000 by Mike Hall. *
'* Please see http://www.brainjar.com for documentation and terms of use. *
'***************************************************************************
preProjectName = Request.ServerVariables("URL")
preProjectName = Replace(preProjectName, "/index.asp", "")
ProjectName = Right(preProjectName, Len(preProjectName)-1)
%>
<% Response.Write(ProjectName)%>
<% Response.Write(ProjectName)%>
<% ListFolderContents(Server.MapPath("/" & ProjectName)) %>
<% 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("" & folder.Files.Count-1 & " files, ")
if folder.SubFolders.Count > 0 then
Response.Write(folder.SubFolders.Count & " directories, ")
end if
Response.Write(Round(folder.Size/1048576,2) & " MB total
" & vbCrLf)
Response.Write("| File | Size [KB] | Last Modified |
" & 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)
excludeFile1 = "/" & ProjectName & "/index.asp"
excludeFile2 = "/" & ProjectName & "/sorttable.js"
If url <> excludeFile1 AND url <> excludeFile2 Then
Response.Write("| " & item.Name & " | " _
& Round(item.Size/1024,2) & " | " _
& item.DateLastModified & " |
" & vbCrLf)
End If
next
Response.Write("
" & 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
%>