SIGN UP MEMBER LOGIN:    
ARTICLE

Advanced File Explorer using C# and Windows Forms

Posted by Shail Srivastav Articles | Windows Forms C# April 12, 2004
The aim is to create an application which (enhanced windows explorer) consists a tree view where someone can see the files available in the existing drives up to certain levels.
Reader Level:
Download Files:
 

The aim is to create an application which (enhanced windows explorer) consists 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. Then when he user selects some file and presses the Compress button, the file gets compressed and like wise it is to be decompressed.

I create a windows application with a tree view showing the files in the drives as in fig 1.The user can expand the 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. (See Figure 1).

Also the Data GroupBox contains a multi-line text box which shows the contents of the selected file.



Figure 1.

This function quits after 4 levels of any branch, actually windows explorer does the same thing. Initially its load only couple of levels and when you click on some branch its reload that branch to deep levels.

If you try o load all the level, then its 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();
}
}

Figure 2.

Login to add your contents and source code to this article
share this article :
post comment
 

I think the example app is a horrible mess. This is not good programming technique.

Posted by Martin Wochinger Feb 21, 2009

Thanks

Posted by shail srivastav Dec 10, 2008

Thx bro very Good Example

Posted by Rashadov Tiger Aug 17, 2008
Posted by lee Apr 13, 2007
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Become a Sponsor