C# 获取文件夹下的所有文件夹及其文件

         //获得当前文件夹下所有文件夹
            string path = "D://文件夹";
            string[] dirstr = Directory.GetDirectories(path);

            //获得当前文件夹下的文件
            string[] filestr = Directory.GetFiles(path);
            int count = 0;
            for (int i = 0; i < filestr.Length; i++)
            {
                string paths = filestr[i];
                StreamReader sr = new StreamReader(paths, Encoding.Default);
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    //Console.WriteLine(line.ToString());
                    bll.Insert(line);
                    count++;
                }
            }

 

posted @ 2017-08-14 14:10  幽冥狂_七  阅读(4436)  评论(0编辑  收藏  举报