Exemple #1
0
 private static void ExportFolderTXT(TextWriter txt, DossierFolderInfo folder, bool simple)
 {
     if (simple)
     {
         txt.WriteLine(folder.FullPath);
     }
     else
     {
         txt.WriteLine();
         txt.WriteLine("{0}\t{1}({2})", Dossier.BytesDisplayText(folder.ReportRecursive.GrandTotal.TotalSize).PadLeft(8), folder.Name, folder.ReportRecursive.GrandTotal.TotalCount);
     }
     foreach (DossierFileInfo file in folder.Files.OrderBy(f => f.Name))
     {
         if (simple)
         {
             txt.WriteLine(file.FullPath);
         }
         else
         {
             txt.WriteLine("{0}\t{1}\t{2}", Dossier.BytesDisplayText(file.Size).PadLeft(8), file.Extension, file.Name);
         }
     }
     foreach (DossierFolderInfo sub in folder.Folders.OrderBy(f => f.Name))
     {
         ExportFolderTXT(txt, sub, simple);
     }
 }
        public DossierFileInfo(string file)
        {
            this.Name = file;

            this.Status = DossierStatus.Unknown;
            this.Type   = Dossier.GetFileType(this.Extension);
        }
Exemple #3
0
 public static void CreateMD5(List <DossierFileInfo> files)
 {
     foreach (DossierFileInfo file in files)
     {
         file.Hash       = Dossier.CalculateMd5(file.FullPath);
         file.IsVerified = true;
         file.Verified   = DateTime.Now;
         file.Status     = DossierStatus.Normal;
     }
 }
        public DossierFileInfo(FileInfo file)
        {
            this.Name       = file.Name;
            this.Size       = file.Length;
            this.Attributes = file.Attributes;
            this.Created    = file.CreationTimeUtc;
            if (file.CreationTimeUtc != file.LastWriteTimeUtc)
            {
                this.Modified = file.LastWriteTimeUtc;
            }

            this.Status = DossierStatus.Normal;
            this.Type   = Dossier.GetFileType(this.Extension);
        }
        public DossierReportInfo Get(string extension, DossierTypes?type = null)
        {
            if (String.IsNullOrWhiteSpace(extension))
            {
                extension = "";
            }
            extension = extension.ToLowerInvariant();
            DossierReportInfo info = this.SingleOrDefault(t => t.Extension == extension);

            if (info == null)
            {
                info           = new DossierReportInfo();
                info.Type      = type.HasValue ? type.Value : Dossier.GetFileType(extension);
                info.Extension = extension;
                base.Add(info);
            }
            return(info);
        }
Exemple #6
0
        public static List <DossierFileInfo> VerifyMD5(List <DossierFileInfo> files)
        {
            List <DossierFileInfo> changes = new List <DossierFileInfo>();

            foreach (DossierFileInfo file in files)
            {
                Guid hash = Dossier.CalculateMd5(file.FullPath);
                file.IsVerified = true;
                file.Verified   = DateTime.Now;
                file.Status     = DossierStatus.Normal;
                if (hash != file.Hash)
                {
                    file.IsVerified = false;
                    file.Verified   = null;
                    file.Status     = DossierStatus.Corrupted;
                    changes.Add(file);
                }
            }

            return(changes);
        }