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