nathan schmoll's
aspdiscovery

back to main page

e-mail me








Listing all files in a directory
Let's say you're building a web-based web site management system and you need to get all the files in a directory. Although you may freak out and say "How do I list the files in a directory?!? Ahhhh!!!", it's really not that hard. Here is how we list all the files in the root directory ("/").

<%
set dir=server.createobject_
("scripting.filesystemobject")
set myfiles=dir.getfolder(server.mappath("/"))
for each filefound in myfiles.files
response.write filefound.name
%>
<br>
<%
next
%>

You can modify this basic code so that each file name can be clicked on and modified or something like that. Sweet.

copyright © 2001, nathan schmoll. all rights reserved. questions? comments? suggestions? e-mail me!