Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
        public DossierFileInfo(string file)
        {
            this.Name = file;

            this.Status = DossierStatus.Unknown;
            this.Type   = Dossier.GetFileType(this.Extension);
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 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);
        }