Click here to Skip to main content
11,927,156 members (52,749 online)
Click here to Skip to main content
Add your own
alternative version


84 bookmarked

Windows Explorer in C#

, 20 May 2002
Rate this:
Please Sign up or sign in to vote.
This is the first in a series of articles demonstrating how to create an

Sample Image


This is the first in a series of articles demonstrating how to create an Explorer-like application. The program uses the following controls: TreeView, ListView, Splitter, MainMenu, StatusBar, Panel, ImageList, and ColumnHeaders for the ListView. Many of the properties are set using the designer, so I would suggest that you download the project, unless of course you are not a beginner.

The program demonstrates the following:

  • How to read files and directories from disk, using the DirectoryInfo instance class.
  • How to populate nodes in a TreeView Control.
  • How to populate the ListView Control.
  • How to use a basic StatusBar.
  • How to use the After_Select Event of the TreeView Control.
  • How to use the Item_Activate Event of the ListView Control.
  • How to use the Load Event of the Form itself.

What I think is best about this program

  1. It is a simple design, which should help you to learn how to use the TreeView Control, It took four revisions.
  2. Compared to many of the other sample or demo programs available,  it loads files and directories fast!
  3. The program only loads the necessary files and folders, not the entire directory tree like many demos do.
  4. The TreeView's Tag property is entirely unused in this implementation, leaving you a place to put something.
  5. There is only one event, and two methods which drive the TreeView control.
  6. This program uses a minimal amount of string chopping, unlike many other demos in it's class.

In closing

This program is designed to show the basics to the beginner, experts will have to wait until I  become an expert! There are too many hard decisions to make when designing an Explorer Interface. So I have made some trade offs to keep the code as readable as possible. I plan to remove the "hard coded" stuff in future releases. 

One of the hardest decisions was to start the root directories at the Drive level instead of nesting under the Desktop\MyComputer nodes, which is what Windows Explorer does. You will also notice that I have turned off the "+" and "-" indicators on the TreeView, this was by design as the code to make this work properly is pretty complex for a beginner, not too mention doubling the code. 

I am disappointed that .NET does not have an easy way (maybe there is) too determine the type of drives attached to the computer. I wanted to use PInvoke, but I figured I would do that in another series or update.

If anyone has any comments please send email:


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

Russell Mangel
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionDO IT IN WIN32 API Pin
Tùng Hoàng22-Sep-15 18:16
memberTùng Hoàng22-Sep-15 18:16 
GeneralMy vote of 5 Pin
nekimiro4-Apr-12 22:32
membernekimiro4-Apr-12 22:32 
QuestionNavigate to a node Pin
maro0096-May-11 11:34
membermaro0096-May-11 11:34 
Generalwindows exploler Pin
ajay1z13-Jan-11 20:31
memberajay1z13-Jan-11 20:31 
Generalimagelist problem Pin
pipicuit6-Jan-09 14:36
memberpipicuit6-Jan-09 14:36 
GeneralRe: imagelist problem Pin
Russell Mangel8-Jan-09 17:16
memberRussell Mangel8-Jan-09 17:16 
QuestionDummy Windows Explorer and Windows Context Menu Pin
Member 36436946-Sep-08 23:46
memberMember 36436946-Sep-08 23:46 
GeneralWeb Based Version Pin
Jim Brooks28-May-08 13:21
memberJim Brooks28-May-08 13:21 
GeneralGreat example but... Pin
sharpiesharpie16-Feb-07 14:32
membersharpiesharpie16-Feb-07 14:32 
GeneralRe: Great example but... Pin
Russell Mangel18-Feb-07 12:23
memberRussell Mangel18-Feb-07 12:23 
GeneralRe: Great example but... Pin
Programm3r18-Nov-07 23:26
memberProgramm3r18-Nov-07 23:26 
QuestionRe: Great example but... Pin
MrColeyted23-Feb-08 13:01
memberMrColeyted23-Feb-08 13:01 
GeneralC# Windows Explorer Pin
tdittmer5-Jan-07 1:56
membertdittmer5-Jan-07 1:56 
GeneralRe: C# Windows Explorer Pin
Russell Mangel5-Jan-07 21:38
memberRussell Mangel5-Jan-07 21:38 
GeneralWindows Explorer in C# Pin
Sagar Joshi25-May-06 3:44
memberSagar Joshi25-May-06 3:44 
GeneralDoesn't sort the directory names Pin
Lyle M9-Feb-06 5:33
memberLyle M9-Feb-06 5:33 
Generalshowplusminus Pin
said_tambal19-Sep-04 3:58
membersaid_tambal19-Sep-04 3:58 
GeneralNice Example Pin
Roger Wright10-May-03 23:42
memberRoger Wright10-May-03 23:42 
GeneralRe: Nice Example Pin
Russell Mangel8-Jun-03 20:56
memberRussell Mangel8-Jun-03 20:56 
GeneralRe: Nice Example Pin
Jonathan de Halleux23-Oct-03 1:02
memberJonathan de Halleux23-Oct-03 1:02 
GeneralRe: Nice Example Pin
Chris Walsh4-Apr-04 16:09
memberChris Walsh4-Apr-04 16:09 
GeneralSmall fix .... Pin
Dejan Petrovic10-Jun-02 18:00
memberDejan Petrovic10-Jun-02 18:00 
GeneralRe: Small fix .... Pin
Russell Mangel8-Jun-03 21:03
memberRussell Mangel8-Jun-03 21:03 
GeneralRe: Small fix .... Pin
schoeneck28-Jan-04 3:55
memberschoeneck28-Jan-04 3:55 
GeneralRe: Small fix .... Pin
pfievhn3-Jun-06 17:26
memberpfievhn3-Jun-06 17:26 
GeneralSmall fix to your small fix... Pin
OICU81TOO28-Nov-06 10:31
memberOICU81TOO28-Nov-06 10:31 
GeneralRe: Small fix .... Pin
--Rob2-Apr-07 20:14
member--Rob2-Apr-07 20:14 

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
Web04 | 2.8.151126.1 | Last Updated 21 May 2002
Article Copyright 2002 by Russell Mangel
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid