List files in a directory


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <%
  2. function getListOfFiles(path)
  3. dim fs, folder, list(), ub
  4. set fs = CreateObject("Scripting.FileSystemObject")
  5. set folder = fs.GetFolder(path)
  6. ub = -1
  7. for each file in folder.Files
  8. ub = ub+1
  9. redim preserve list(ub)
  10. list(ub) = file.Name
  11. next
  12. getListOfFiles = list
  13. end function
  14.  
  15. dim files : files = getListOfFiles(server.MapPath("/images"))
  16. for each name in files
  17. response.Write(name&"<br>")
  18. next
  19. %>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.