public static List<string> GetFile(string path, List<string> FileList, string RelativePath) { DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] fil = dir.GetFiles(); DirectoryInfo[] dii = dir.GetDirectories(); foreach (FileInfo f in fil) { //int size = Convert.ToInt32(f.Length); //long size = f.Length; FileList.Add(f.FullName);//添加文件路径到列表中 } //获取子文件夹内的文件列表,递归遍历 foreach (DirectoryInfo d in dii) { GetFile(d.FullName, FileList, RelativePath); } return FileList; }