Posted By

elightbo on 10/03/08


Tagged

sitemap


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

nelda751


ASP folder nav


 / Published in: ASP
 

Lists folders and files within given folder.

  1. function ListFolderContents(path,displayRoot)
  2. dim fs, folder, file, item, url
  3.  
  4. set fs = CreateObject("Scripting.FileSystemObject")
  5. set folder = fs.GetFolder(path)
  6.  
  7. 'Display the target folder and info.
  8. if displayRoot = true then
  9. Response.Write("<li><strong><a href=""" & MapURL(folder) & """>" & folder.Name & "</a></strong>")
  10. Response.Write "<ul>" & vbcrlf
  11. end if
  12.  
  13. 'Display a list of sub folders.
  14. for each item in folder.SubFolders
  15. ListFolderContents item.Path, true
  16. next
  17.  
  18. 'Display a list of files.
  19. for each item in folder.Files
  20. if item.name <> "index.asp" and item.name <> "index.htm" and item.name <> "index.html" then
  21. url = MapURL(item.path)
  22. Response.Write("<li><a href=""" & url & """>" _
  23. & item.Name & "</a>" _
  24. & "</li>" & vbCrLf)
  25. end if
  26. next
  27.  
  28. if displayRoot = true then
  29. Response.Write "</ul>" & vbcrlf
  30. Response.Write "</li>"
  31. end if
  32. end function

Report this snippet  

You need to login to post a comment.