///
/// 初始化树
///
public void InitTree()
{
TreeNode root = new TreeNode("所有磁盘");
DriveInfo[] drives = DriveInfo.GetDrives(); //获取计算上的逻辑驱动器
//循环将所有磁盘添加到根节点
for (int i = 0; i < drives.Length; i++)
{
TreeNode drive = new TreeNode(drives[i].ToString());
root.Nodes.Add(drive);
drive.Tag = drive.Text;
drive.Text = drive.Text.Substring(0, 2);
GetFiles(drive);
}
this.treeView1.Nodes.Add(root); //将根节点添加到树中
}
没分:--(