DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Simple FSO Directory File Listing
// simple browsing tool
<%
dim aryURL, URLvar
aryURL = Split(Request.ServerVariables("SCRIPT_NAME"), "/", -1, 1)
URLvar = aryURL(ubound(aryURL))
if request.querystring("sPP")<>"" then
sPP=request.querystring("sPP") & "\"
ParentVar="<a href=""#"" onClick=""history.go(-1)"">Parent Directory</a><br><br>" & vbCrLF
else
sPP = "\\serverlocation\"
end if
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each f1 in ff
HeaderVar=HeaderVar& "<a href=""" & URLvar & "?sPP=" & sPP & f1.name & """>" & f1.name & "</a> | " & vbCrLF
Next
For Each f1 in fc
SubHeaderVar=SubHeaderVar& "<a href=""" & sPP & f1.name & """>" & f1.name & "</a> <br>" & vbCrLF
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
response.write ParentVar
if HeaderVar<>"" then response.write "<b>Folders" & vbCrLF & "<br><br> | " & vbCrLF & HeaderVar & "</b><br><br>" & vbCrLF
if SubHeaderVar<>"" then response.write "<b>Files</b>" & vbCrLF & "<br><br>" & vbCrLF & SubHeaderVar & vbCrLF
%>




