亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C# 遞歸查找樹狀目錄實(shí)現(xiàn)方法

 更新時(shí)間:2014年02月15日 16:49:40   作者:  
這篇文章主要介紹了C# 遞歸查找樹狀目錄實(shí)現(xiàn)方法,需要的朋友可以參考下

1.遞歸查找樹狀目錄

復(fù)制代碼 代碼如下:

 public partial class Form1 : Form
    {
        string path = @"F:\學(xué)習(xí)文件";//遞歸查找樹狀目錄
        public Form1()
        {遞歸查找樹狀目錄
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadTree(path);
        }

 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);
                }
            }
        }
    }
}

相關(guān)文章

最新評論