/ Published in: ASP
Lists folders and files within given folder.
Expand |
Embed | Plain Text
function ListFolderContents(path,displayRoot) dim fs, folder, file, item, url set fs = CreateObject("Scripting.FileSystemObject") set folder = fs.GetFolder(path) 'Display the target folder and info. if displayRoot = true then Response.Write("<li><strong><a href=""" & MapURL(folder) & """>" & folder.Name & "</a></strong>") Response.Write "<ul>" & vbcrlf end if 'Display a list of sub folders. for each item in folder.SubFolders ListFolderContents item.Path, true next 'Display a list of files. for each item in folder.Files if item.name <> "index.asp" and item.name <> "index.htm" and item.name <> "index.html" then url = MapURL(item.path) Response.Write("<li><a href=""" & url & """>" _ & item.Name & "</a>" _ & "</li>" & vbCrLf) end if next if displayRoot = true then Response.Write "</ul>" & vbcrlf Response.Write "</li>" end if end function
You need to login to post a comment.
