Directory Listing
<%' Now to the Runtime code:
Dim strPath 'Path of directory to show
Dim objFSO 'FileSystemObject variable
Dim objFolder 'Folder variable
Dim objItem 'Variable used to loop through the contents of the folder
' You could just as easily read this from some sort of input, but I don't
' need you guys and gals roaming around our server so I've hard coded it to
' a directory I set up to illustrate the sample.
' NOTE: As currently implemented, this needs to end with the /
strPath = "./"
' Create our FSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
' Get a handle on our folder
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
' First I deal with any subdirectories. I just display them and when you
' click you go to them via plain HTTP.
For Each objItem In objFolder.SubFolders
' Deal with the stupid VTI's that keep giving our visitors 404's
If InStr(1, objItem, "_vti", 1) = 0 Then
%>
<TR BGCOLOR="#CCFFCC">
<TD ALIGN="left" ><A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD>
</TR>
<%
End If
Next 'objItem
' All done! Kill off our object variables.
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.