Example #1
0
        private static void DeleteArchive(FileInfo archiveFile)
        {
            FileInfo fileInfo = FileBasedArchiveService.MetaFilePath(archiveFile);

            archiveFile.Delete();
            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }
        }
Example #2
0
 public BeginArchive Create(string name, Action <ArchiveCreated> onCreated = null)
 {
     return(new BeginArchive(name, (MemoryStream stream, ArchiveOptions options) => {
         string str = Guid.NewGuid().ToString("N");
         Directory.CreateDirectory(this._baseDirectory);
         FileInfo fileInfo = new FileInfo(Path.Combine(this._baseDirectory, string.Format("{0}.zip", str)));
         File.WriteAllBytes(fileInfo.FullName, stream.ToArray());
         File.WriteAllText(FileBasedArchiveService.MetaFilePath(fileInfo).FullName, (new FileBasedArchiveService.MetaFile(options)).ToString());
         if (onCreated != null)
         {
             onCreated(new ArchiveCreated(str, new string[0]));
         }
     }));
 }
Example #3
0
        private FileBasedArchiveService.MetaFile ReadMetaFile(FileInfo archiveFile)
        {
            FileInfo fileInfo = FileBasedArchiveService.MetaFilePath(archiveFile);

            if (!fileInfo.Exists)
            {
                return(null);
            }
            string str = File.ReadAllText(fileInfo.FullName);

            if (string.IsNullOrWhiteSpace(str))
            {
                return(null);
            }
            return(FileBasedArchiveService.MetaFile.FromJson(str, this._logger));
        }