ASP 101 - Active Server Pages 101 - Web04
The Place ASP Developers Go!

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

Script Output:
Contents of ./dir/

File Name: File Size (bytes): Date Created: File Type:
 sample 155 3/26/2009 9:12:11 AM File Folder
 default.asp 4141 9/10/2007 8:35:28 AM ASP File
 default.aspx 5239 11/27/2007 4:06:56 PM ASPX File
 sample.asp 394 3/9/2001 4:56:23 PM ASP File
 sample.gif 3657 3/9/2001 4:56:23 PM GIF Image
 sample.htm 386 3/9/2001 4:56:23 PM HTML Document
 sample.jpg 11721 3/9/2001 4:56:23 PM JPEG Image
 sample.rtf 393 3/9/2001 4:56:23 PM Rich Text Document
 sample.txt 126 3/9/2001 4:56:23 PM Text Document

ASP HTML Download            FAQ

ASP.NET Version

For the most part, I try to discourage users from browsing around the directory structure of the sites we develop. There are times however when letting a user look around and see what files are there is helpful. You could simply allow directory browsing for that directory, but then you've got to remember that you set that setting so you or someone else doesn't accidently override it not to mention that it's not very nice looking to drop from your custom designed extranet frontend to IIS's pathetic looking directory list. Not like I really care (heck I'd rather have the bare bones display and save the bandwidth) but stop and think about your visitors for a second. You know, the ones who go ooh and aah over your pretty color scheme!

This script is just a quick example of a way to get the best of both worlds. You can get the nice display, but not have to maintain the links since they're generated from the directories and files themselves! Add a new file and like magic it appears on the page. Delete one and... well you get the idea!

This script should work as is for displaying one directory. Just set the directory you want to show. You may want to create your own icons or add file types, but those are left up to you. The next natural progression would be to take the folder links and pass them back through the script so that people could browse the directory tree of your entire site all from this one little page. Cool huh! A little scary too, but cool none the less!

Update: Recursive Version

One of our most frequently asked questions comes from this very sample. The question everyone seems to want answered is how do you write a version of the script that will traverse sub-folders that I mentioned above. It's really quite simple... take a look at the code and see for yourself.

I don't have this particular script running live on the server, but you can download a zip file containing it from here: (1.3 KB).

I've also written an ASP.NET 1.x version for those of you using ASP.NET. You can find it here: (1.3 KB).


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers