C#遍历目录下所有文件

        void GetDir(string dir)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(dir);
            var directroies = directoryInfo.GetDirectories();
            foreach (var directroy in directroies)
            {

               // Console.WriteLine(directroy.FullName);
                GetDir(directroy.FullName);

               var list= directroy.GetFiles();
                foreach (var file in list)
                {
                    Console.WriteLine(file.FullName);
                }
            }
        }

 

posted @ 2022-06-22 22:14  来了啊老弟  阅读(135)  评论(0编辑  收藏  举报