C#递归获取文件目录

时间:2022-08-23 12:06:55

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PathClass
{
    class Program
    {
        static void Main(string[] args)
        {
            fun(@"E:\doNetBook");
            Console.ReadKey();
        }

        public static void fun(string path)
        {
            string[] fileDirectory = Directory.GetDirectories(path);
            foreach (var item in fileDirectory)
            {
                Console.WriteLine(item);
                fun(item);
            }

        }
    }
}

 

C#递归获取文件目录