1 文件资源管理器的递归
private void LoadTree(string path,TreeNode node)
{
string[] dirs = Directory.GetDirectories(path);
foreach (string dir in dirs)
{
TreeNode node1 = new TreeNode(Path.GetFileName(dir));
if (node == null) //根节点
{
tvMain.Nodes.Add(node1);
}
else
{
node.Nodes.Add(node1);
}
if (Directory.GetDirectories(dir).Length > 0)
{
LoadTree(dir, node1);
}
}
}
2 省市的递归