如何获取磁盘下的文件及子文件夹呢?
目前代码如下
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using
namespace myManager
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
TreeNode rootNode = this.treeView1.Nodes[0];
rootNode.Expand();
TreeNode ndMyComputer = null;
TreeNode ndMyDocument = null;
foreach (TreeNode nd in rootNode.Nodes)
{
if (nd.Name == "ndMyComputer")
{
ndMyComputer = nd;
}
if (nd.Name == "ndMyDocument")
{
ndMyDocument = nd;
}
}
// 添加我的电脑里边的子节点
DriveInfo[] drivers = DriveInfo.GetDrives();
foreach (DriveInfo driver in drivers)
{
ListViewItem item = listView1.Items.Add(driver.Name);
item.Name = driver.Name;
TreeNode node = new TreeNode(driver.Name);
ndMyComputer.Nodes.Add(node);
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
接下来改怎么实现代码呢?实现文件夹及子文件在树的左边显示出来,在右边也相应的显示出来