<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> Documento senza titolo

ASP Directory Listing Demo

Three separate directories from the web server root are displayed below ("asp", "dhtml" and "js"), showing all subdirectories and files. Additionally, each file is displayed as a link.

<% 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.Name & " - " _ & 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("" & vbCrLf) 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 %>