转载:http://www.cnblogs.com/lori/p/3529936.html
代码:
static void GetFiles(List<string> arr, string dir) { arr.AddRange(Directory.GetFiles(dir)); var subDir = Directory.GetDirectories(dir).ToList(); if (subDir != null && subDir.Count > 0) subDir.ForEach(j => { GetFiles(arr, j); }); }
调用:
List<string> path = new List<string>(); GetFiles(path, @"C:UsersAdministratorDesktop新建文件夹");
结果如图: