private static System.Collections.Hashtable getAllFies(string filesdirectorypath, out int dirnamelength) { System.Collections.Hashtable hashtable = new System.Collections.Hashtable(); System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(filesdirectorypath); if (!directoryInfo.Exists) { throw new System.IO.FileNotFoundException("目录:" + directoryInfo.FullName + "没有找到!"); } dirnamelength = directoryInfo.Name.Length; FileOperate.getAllDirFiles(directoryInfo, hashtable); FileOperate.getAllDirsFiles(directoryInfo.GetDirectories(), hashtable); return(hashtable); }
private static void getAllDirsFiles(System.IO.DirectoryInfo[] dirs, System.Collections.Hashtable filesList) { for (int i = 0; i < dirs.Length; i++) { System.IO.DirectoryInfo directoryInfo = dirs[i]; System.IO.FileInfo[] files = directoryInfo.GetFiles("*.*"); for (int j = 0; j < files.Length; j++) { System.IO.FileInfo fileInfo = files[j]; filesList.Add(fileInfo.FullName, fileInfo.LastWriteTime); } FileOperate.getAllDirsFiles(directoryInfo.GetDirectories(), filesList); } }