My ASP.NET FileSystem Browser Revisited

.NET ,Fun Stuff
November 17, 2007

More than 2 years ago I wrote this article and submitted it in CodeProject detailing how you can build a FileSystem Browser in ASP.NET. The article talks about how newbie ASP developers moving to ASP.NET might code the solution and how somebody a little bit more familiar with ASP.NET would build the same application in lesser code.

Somebody emailed me about my article yesterday asking for some guidance. This lead me to inspect my old article. The first thing i said to myself after seeing my old code is ‘Yikes! I did that?’. Yup, it was that horrible. The solution works, its functional based on the need but I knew i could clean it up and code it much better if i had the chance to do it a second time around. That chance happened today.

I haved changed the way i read folders(before it was using query strings). I have replaced that logic by placing the path inside my LinkButton CommandArgument property. How i pass the FileSystemInfo[] to the grid(it was using an intermediate datatable) and the type of control that displays the data(it was using a datagrid before now we are using a gridview). I’ve also added a breadcrumb like control to track the users location and made it a little bit prettier by adding icons instead of plain text descriptions.

I’ll be updating this constantly based on the request I haved received from my original article. The most common request is sorting which I will add on the next release.

Hopefully this version is less crappier than the last.


Thanks to Andreas Haydeck for pointing out a bug in the BuildNavigatorPath method that causes the navigator path not to show the proper folder location. This has been fixed and the code in this article has been updated.

Download the latest source here: (6.57 KB)

7 thoughts on “My ASP.NET FileSystem Browser Revisited”

  1. Ivan says:

    Hello Keith! I liked ur FileSystem browser very much and want to use it on my website. But i can’t make ur application work – i always get "You dont have access to view this folder." I’ve changed path from "c:Dell" to "test", granted all access to this folder, but nothing i got – still no access. I’m not a programmer, just user, so please, explain me what to do?
    Thanks in advance.

    P.S.: sorry for bad English, i’m from Russia.

  2. Ivan says:

    I’ve found out that ur program does not support relative paths, am I right? Could you fix it, please?

  3. Keith Rull says:


    what you could do is change the the variable CONST_RootFolder from this:
    private string const CONST_RootDirectory = @"C:Dell";

    to this: private string CONST_RootDirectory = String.Empty;

    then change the page_load event to this:
    protected void Page_Load(object sender, EventArgs e)
    //this is your initial path
    CONST_RootDirectory = this.MapPath("");
    if (!IsPostBack)

    what the code above does is that it sets the CONST_RootDirectory variable to the applications path which in your case would be:

    //this code defaults the folder brower to a folder called test
    CONST_RootDirectory = this.MapPath("test");


  4. Gianpaolo says:


    It is very nice, is possible view with format/style Treeview


  5. Keith Rull says:

    Yes it is possible to do it that way but you need to change the code. Just change the control to a treeview and bind the proper columns to the treeview node.

  6. Brendan says:

    great post!
    This is what i was looking for. I am new to programming and this gives me a nice example and starting point for a project I am working on.

  7. Sai Chander A says:

    pretty beautiful post. I am having hard time converting this one to Listview rather than gridview. Can u help

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.