一些递归

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 省市的递归

posted @ 2013-11-21 23:23  陌念  阅读(127)  评论(0编辑  收藏  举报