Ejemplo n.º 1
0
        private void CreateZipButton_Click(object sender, RoutedEventArgs e)
        {
            if (File.Exists(targetFile.GetFilePathWithTimeStamp()))
            {
                StatusString.Text = "Fil finns redan";
                return;
            }

            //StatusString.Text = "Skapar zip-fil";
            try
            {
                //ZipArchiver.CreateBackup(baseDir.GetPath(), targetFile.GetFilePathWithTimeStamp());
                ZipFileWithProgress.CreateFromDirectory(baseDir.GetPath(), targetFile.GetFilePathWithTimeStamp(),
                                                        new BasicProgress <double>(p => StatusString.Text = $"{p:P2} av zip-filen är färdig"));
                StatusString.Text = "Zip-fil skapades";
            }
            catch (ArgumentNullException)
            {
                UpdateStatusPickFolder();
            }
            catch (DirectoryNotFoundException)
            {
                StatusString.Text = "Du har valt en mapp som inte finns";
            }
        }
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        string sourceDirectory     = args[0],
               archive             = args[1],
               archiveDirectory    = Path.GetDirectoryName(Path.GetFullPath(archive)),
               unpackDirectoryName = Guid.NewGuid().ToString();

        File.Delete(archive);
        ZipFileWithProgress.CreateFromDirectory(sourceDirectory, archive,
                                                new BasicProgress <double>(p => Console.WriteLine($"{p:P2} archiving complete")));
        ZipFileWithProgress.ExtractToDirectory(archive, unpackDirectoryName,
                                               new BasicProgress <double>(p => Console.WriteLine($"{p:P0} extracting complete")));
    }
Ejemplo n.º 3
0
 public static void CreateBackup(string baseDirPath, string targetFilePath)
 {
     ZipFileWithProgress.CreateFromDirectory(baseDirPath, targetFilePath,
                                             new BasicProgress <double>(p => Console.WriteLine($"{p:P2} archiving complete")));
 }