View Code
1 public static List<string> GetRootPathAllFiles(this string rootPath) 2 { 3 var items = new List<string>(); 4 items.AddRange(Directory.GetFiles(rootPath)); 5 var dirlist = Directory.GetDirectories(rootPath); 6 if (dirlist.Length > 0) 7 { 8 foreach (string item in dirlist) 9 { 10 items.AddRange(GetRootPathAllFiles(item)); 11 } 12 } 13 return items; 14 }
获取一个目录下所有的文件