标签:dir dict 列表 文件路径 rect ret name 全路径 param
/// <summary> /// 获取路径下所有文件以及子文件夹中文件 /// </summary> /// <param name="path">全路径根目录</param> /// <param name="FileList">存放所有文件的全路径</param> /// <param name="RelativePath"></param> /// <returns></returns> public static Dictionary<string, long> GetFile(string path, Dictionary<string, long> 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, size);//添加文件路径到列表中 } //获取子文件夹内的文件列表,递归遍历 foreach (DirectoryInfo d in dii) { GetFile(d.FullName, FileList, RelativePath); } return FileList; }
标签:dir dict 列表 文件路径 rect ret name 全路径 param
原文地址:https://www.cnblogs.com/picps/p/9449115.html