Click here to Skip to main content
Licence 
First Posted 20 Apr 2004
Views 59,288
Bookmarked 42 times

Advanced File Explorer

By | 20 Apr 2004 | Article
An enhanced Windows Explorer application which consists of a tree view where someone can see the files available in the existing drives up to certain levels.

Introduction

The aim is to create an application which (is enhanced Windows Explorer) consists of a tree view where someone can see the files available in the existing drives, up to certain levels. (In this case, 4). You can easily change it to any level you want. Also, when someone selects a file from the tree view, we need to display the different properties of this file in the labels in the group box.

I create a Windows application with a tree view showing the files in the drives as in fig 1.The user can expand them up to 4 levels to see the files/directories. The details of the selected file or folder like the file name, date created, size etc. are shown in the labels in the Details GroupBox (Fig 1). Also the Data GroupBox contains a multi-line text box which shows the contents of the selected file.

Fig 1

This function quits after 4 levels of any branch. Actually Windows Explorer does the same thing. Initially, it loads only couple of levels and when you click on some branch, it reloads that branch to deep levels.

If you try to load all the levels, then it's going to take up to 2-5 minutes depending upon your machine speed.

private void FillDirectory(string drv, TreeNode parent, int level)
{
    try
    {
        // I want to go only upto 4 level.
        level++;
        if (level > 4)
            return;
        DirectoryInfo dir = new DirectoryInfo(drv);
        if (!dir.Exists)
            throw new DirectoryNotFoundException
                ("directory does not exist:"+drv);
            foreach(DirectoryInfo di in dir.GetDirectories())
        {
            TreeNode child = new TreeNode();
            child.Text = di.Name;
            parent.Nodes.Add(child);

            FillDirectory(child.FullPath, child, level);
        }
    }
    catch(Exception ex)
    {
        ex.ToString();
    }
}

Fig 2.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shail_Srivastav

Web Developer

United States United States

Member

Shail Srivastav
shailsrivastav@hotmail.com
Resume


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionwere is the code? PinmemberMember 417923022:44 15 Apr '08  
QuestionEnhanced? PinmemberCodeX555:49 6 Sep '07  
GeneralNo need to hard code branch limits [modified] Pinmemberdfhgesart3:31 1 Jul '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 21 Apr 2004
Article Copyright 2004 by Shail_Srivastav
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid