Using the
File System Object
to
Display Directory Content
:
Click here to test this script.
Code:
Place below the <HTML> tag:
Highlight
<% Function BuildDirectory(strDir) dim objFileSystem dim objDirectory set objFileSystem = Server.CreateObject("Scripting.FileSystemObject") set objDirectory = objFileSystem.GetFolder(Server.MapPath(strDir)) Response.Write "
" For each File in objDirectory.Files url = MapURL(Server.mapPath(strDir)) & "/" & Replace(File,objDirectory & "\","") Response.Write("
" & Replace(File, objDirectory & "\","") & "
") Next Response.Write "
" end function function MapURL(path) dim rootPath dim url rootPath = Server.MapPath("/") url = Right(path, Len(path) - Len(rootPath)) MapURL = Replace(url, "\", "/") end function %>
Place in the <BODY>:
Highlight
<%BuildDirectory"."%>