示例#1
0
文件: bFolderInfo.cs 项目: bivy/bdub
 private static int CountFiles(bFolderInfo folderInfo)
 {
     int count = folderInfo.Files.Count;
     foreach (bFolderInfo folder in folderInfo.Folders)
     {
         count += folder.CountFiles();
     }
     return count;
 }
示例#2
0
 public static bFileInfo CreateFileInfo(FileInfo fileInfo, int hashingSize, bFolderInfo folderInfo)
 {
     try
     {
         bFileInfo bfi = new bFileInfo();
         bfi.Name = fileInfo.Name;
         bfi.Size = fileInfo.Length;
         bfi.DateTime = fileInfo.LastWriteTime;
         bfi.Hash = CalcHash(fileInfo, hashingSize);
         bfi.ParentFolderCode = folderInfo.Code;
         return bfi;
     }
     catch
     {
         return null;
     }
 }
示例#3
0
 public bFolderInfo ScanFolder(string folder, bFolderInfo parentFolder)
 {
     SendProgressString(folder);
     bFolderInfo folderInfo = new bFolderInfo();
     folderInfo.Code = Guid.NewGuid().ToString();
     folderInfo.ParentFolderCode = parentFolder == null ? null : parentFolder.Code;
     folderInfo.Title = Path.GetDirectoryName(folder);
     DirectoryInfo di = new DirectoryInfo(folder);
     foreach (FileInfo fileInfo in di.GetFiles(FileMasks))
     {
         bFileInfo bfi = CreateFileInfo(fileInfo, HashingSize, folderInfo);
         if (bfi == null)
             continue;
         folderInfo.Files.Add(bfi);
     }
     if (ScanSubfolders)
     {
         foreach (DirectoryInfo directoryInfo in di.GetDirectories("*.*"))
         {
             folderInfo.Folders.Add(ScanFolder(directoryInfo.FullName, folderInfo));
         }
     }
     return folderInfo;
 }