Thursday, February 4, 2010

This will give treeview of all drives on hard disk

foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
TreeNode node = new TreeNode();
node.Value = drive.Name;
//Make sure the drive is ready before we access it
if (drive.IsReady)
{
node.Text = drive.Name + " - (free space: " + drive.AvailableFreeSpace + ")";
this.TreeView1.Nodes.Add(node);
}
else
{
node.Text = drive.Name + " - (not ready)";
this.TreeView1.Nodes.Add(node);
}
}

No comments:

Post a Comment