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

Please visit our partners

Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
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 1/31/2007 12:11:35 PM 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: dir_list_recursive.zip (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: dir_list_recursive_aspx.zip (1.3 KB).


Samples

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES