1.递归查找树状目录
public void LoadTree(string path, TreeNode node=null)
{
string[] dirs = Directory.GetDirectories(path);//获取子目录
foreach (string dir in dirs)
{
TreeNode node1 = new TreeNode(Path.GetFileName(dir));
//TreeNode node1 = new TreeNode(dir);//文件所有路径
if (node == null)
{
treeView1.Nodes.Add(node1);
}
else
{
node.Nodes.Add(node1);
}
if (Directory.GetDirectories(dir).Length > 0)
{
LoadTree(dir, node1);
}
}
}
}
}
新闻热点
疑难解答