Click here to Skip to main content
12,241,975 members (46,510 online)
Click here to Skip to main content
Add your own
alternative version


38 bookmarked

Simple Web Browse

, 26 Apr 2004 CC (ASA 2.5)
Rate this:
Please Sign up or sign in to vote.
File and directory browser application in ASP.NET.

Sample Image - webbrowse0070.jpg


This article is about a simple directory & file browser for the web. The browser displays a list of files and directories of the directory where it is placed.

Using the script

  • Place the script file, default name Browse0070.aspx within the root / sub directory of your web server.
  • Rename the script if desired, and link to the script...
  • Example link.
    <A href="Browse0070.aspx">Browse</A>

How it Works

This is a rather simple script when it come to the actual core of the code... Loops are preformed for each directory / file entry with the directory it's been pointed to... For each directory it prints, it adds a link for that directory to itself, making the script able to surf though the file system. The snippet below displays the file output code...

//Ouput files
FileInfo[] oFiles = oDirInfo.GetFiles();
foreach(FileInfo oFile in oFiles){
        Response.Write("<TR><TD class=\"tdFile\"><A href=\""+...


  • Script is contained in one file for easy usage / implementation
  • Page title can be set via the title variable
  • Return link can be set via the link variable
  • Script can be renamed to any filename, e.g.. default.aspx
  • The name of the script file, will not appear in the output
  • Displays in KB and MB
  • Only displays the root and sub directory below itself for security


  • 28th April 2004 - Build 0070
    • Rewritten from VB.NET to C#, small visual and running changes.
    • Renamed from "File Browser" to "Web Browse".
    • Posted on CodeProject.
  • Build 0063
    • Optimizations and tidying of the code, moved to the build version system.
  • Build 0062
    • Added better error checking, now displays errors on the page.
  • Build 0061
    • Link now passes correctly when using a link from the crumb bar.
  • Build 0060
    • "link" option for returning to main page, etc.
    • Script produced errors when it encounters a write protected directory, now displays as "Access Denied" next to the name.
    • The title would reset after entering a directory, details are now retained from page to page when navigating.
  • Build 0030-0050
    • File size is displayed in KB and MB.
    • Left / right alignment in columns, instead of all left.
    • Added "title" option for returning to main page, etc.
    • New layout, colors, and tidied output.
    • First build to appear online.


This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-ShareAlike 2.5 License


About the Author

Web Developer
New Zealand New Zealand
C#, (Web and forms), SQL Server, MySQL, ASP, Win32 API, ...

You may also be interested in...

Comments and Discussions

Questiongreat Pin
Member 944777826-Sep-12 7:26
memberMember 944777826-Sep-12 7:26 
GeneralMy vote of 3 Pin
clodiny10-Mar-12 1:23
memberclodiny10-Mar-12 1:23 
QuestionPLease apply ajax in this Pin
Member 828063517-Jan-12 3:52
memberMember 828063517-Jan-12 3:52 
GeneralNetwork Shares Pin
BIGDO21-Nov-07 4:08
memberBIGDO21-Nov-07 4:08 
Questionbring back the VB version Pin
zenuke4-Jun-07 3:22
memberzenuke4-Jun-07 3:22 
AnswerRe: bring back the VB version Pin
aejw4-Jun-07 5:48
memberaejw4-Jun-07 5:48 
GeneralGREAT! - please read: Pin
Avshash8-Apr-07 23:48
memberAvshash8-Apr-07 23:48 
GeneralRe: GREAT! - please read: Pin
aejw9-Apr-07 3:42
memberaejw9-Apr-07 3:42 
NewsNetwork Shares... Pin
aejw28-Mar-07 6:13
memberaejw28-Mar-07 6:13 
GeneralThanks! Pin
stupidstanly14-Mar-07 5:59
memberstupidstanly14-Mar-07 5:59 
GeneralRe: Thanks! Pin
aejw15-Mar-07 0:51
memberaejw15-Mar-07 0:51 
GeneralThanks! Pin
UV200330-Apr-06 8:06
memberUV200330-Apr-06 8:06 
GeneralDont write inline HTML Pin
Bobby Ryzhy14-Jul-04 13:21
memberBobby Ryzhy14-Jul-04 13:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 27 Apr 2004
Article Copyright 2004 by aejw
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid