文件递归遍历

文件递归遍历

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.IO;

 

namespace ConsoleApplication6

{


class
Program

{


static
void Main(string[] args)

{

getFiles(@”C:\Users\xudajun\Desktop\S7200″);

}

 


private
static
void getFiles(string path)

{


string[] strFileName = Directory.GetFiles(path);


string[] strDirectories = Directory.GetDirectories(path);

 


foreach(string i in strFileName)

{


Console.WriteLine(i);

}


foreach(string i in strDirectories)

{


Console.WriteLine(i);

getFiles(i);

}

 

}

}

 

}