C#递归获取文件目录

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

        }
    }
}

 

 

posted @ 2012-09-14 23:00  MXi4oyu  阅读(247)  评论(0编辑  收藏  举报