Ejemplo n.º 1
0
        void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error");
                Application.Exit();
            }
            lblStatus.Text = "Decompressing...";
            probar.Style = ProgressBarStyle.Blocks;
            SevenZipExtractor extractor = new SevenZip.SevenZipExtractor(Application.StartupPath + "\\Update.zip");
            extractor.Extracting += new EventHandler<ProgressEventArgs>(extractor_Extracting);
            extractor.ExtractionFinished += new EventHandler<EventArgs>(extractor_ExtractionFinished);

            extractor.BeginExtractArchive(Application.StartupPath);
        }
Ejemplo n.º 2
0
        void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error");
                Application.Exit();
            }
            lblStatus.Text = "Decompressing...";
            probar.Style   = ProgressBarStyle.Blocks;
            SevenZipExtractor extractor = new SevenZip.SevenZipExtractor(Application.StartupPath + "\\Update.zip");

            extractor.Extracting         += new EventHandler <ProgressEventArgs>(extractor_Extracting);
            extractor.ExtractionFinished += new EventHandler <EventArgs>(extractor_ExtractionFinished);

            extractor.BeginExtractArchive(Application.StartupPath);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Extracts and archive to the given directory
 /// </summary>
 /// <param name="inFile">Path to the archive to extract</param>
 /// <param name="outDir">The path to the target directory for extraction</param>
 public static void ExtractArchive(string inFile, string outDir)
 {
     SevenZipBase.SetLibraryPath(PathHelper.SevenZipLibrary);
     try
     {
         _extractor = new SevenZipExtractor(inFile);
         if (!Directory.Exists(outDir))
             Directory.CreateDirectory(outDir);
         _extractor.ExtractionFinished += ExtractorExtractionFinished;
         _extractor.BeginExtractArchive(outDir);
     }
     catch
     {
         MessageBox.Show("Failed to extract ARChive.",
             "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public static Task Extract7zAsync(string file, string outDir, IProgress<int> progress)
        {

            return Task.Run(() =>
            {

                var libPath = Path.Combine("7zip", "7z.dll");

                SevenZipExtractor.SetLibraryPath(libPath);
                SevenZipExtractor extractor = new SevenZipExtractor(file);

                ManualResetEvent mre = new ManualResetEvent(false);

                extractor.Extracting += (sender, e) => progress.Report(e.PercentDone);
                extractor.ExtractionFinished += (sender, e) => mre.Set();

                extractor.BeginExtractArchive(outDir);

                mre.WaitOne();

            });


        }
Ejemplo n.º 5
0
        private void miExtractHere_Click(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(
                              System.Windows.Threading.DispatcherPriority.Background,
                              new ThreadStart(
                                delegate()
                                {

                                    string FileName = Explorer.SelectedItems[0].ParsingName;
                                    SevenZipExtractor extractor = new SevenZipExtractor(FileName);
                                    string DirectoryName = System.IO.Path.GetDirectoryName(FileName);
                                    string ArchName = System.IO.Path.GetFileNameWithoutExtension(FileName);
                                    extractor.Extracting += new EventHandler<ProgressEventArgs>(extractor_Extracting);
                                    extractor.ExtractionFinished += new EventHandler<EventArgs>(extractor_ExtractionFinished);
                                    extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extractor_FileExtractionStarted);
                                    extractor.FileExtractionFinished += new EventHandler<FileInfoEventArgs>(extractor_FileExtractionFinished);
                                    extractor.PreserveDirectoryStructure = true;
                                    string Separator = "";
                                    if (DirectoryName[DirectoryName.Length - 1] != Char.Parse(@"\"))
                                    {
                                        Separator = @"\";
                                    }
                                    AddToLog("Extracted Archive to " + DirectoryName + Separator + ArchName + " from source " + FileName);
                                    extractor.BeginExtractArchive(DirectoryName + Separator + ArchName);
                                }));
        }
Ejemplo n.º 6
0
 private void b_Extract_Click(object sender, EventArgs e)
 {
     SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
     string fileName = tb_ExtractArchive.Text;
     string directory = tb_ExtractDirectory.Text;
     var extr = new SevenZipExtractor(fileName);
     pb_ExtractWork.Maximum = (int)extr.FilesCount;
     extr.Extracting += new EventHandler<ProgressEventArgs>(extr_Extracting);
     extr.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
     extr.FileExists += new EventHandler<FileOverwriteEventArgs>(extr_FileExists);
     extr.ExtractionFinished += new EventHandler<EventArgs>(extr_ExtractionFinished);
     extr.BeginExtractArchive(directory);
 }
Ejemplo n.º 7
0
 private void b_Extract_Click(object sender, RoutedEventArgs e)
 {
     SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
     tb_Messages.Text = "Started" + Environment.NewLine;
     string fileName = tb_ExtractArchive.Text;
     string directory = tb_ExtractFolder.Text;
     var extractor = new SevenZipExtractor(fileName);
     extractor.Extracting += new EventHandler<ProgressEventArgs>(extr_Extracting);
     extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
     extractor.FileExists += new EventHandler<FileOverwriteEventArgs>(extr_FileExists);
     extractor.ExtractionFinished += new EventHandler<EventArgs>(extr_ExtractionFinished);
     extractor.BeginExtractArchive(directory);
 }
Ejemplo n.º 8
0
 private void miExtractHere_Click(object sender, RoutedEventArgs e) {
   string FileName = _ShellListView.GetFirstSelectedItem().ParsingName;
   var extractor = new SevenZipExtractor(FileName);
   string DirectoryName = Path.GetDirectoryName(FileName);
   string ArchName = Path.GetFileNameWithoutExtension(FileName);
   extractor.Extracting += new EventHandler<ProgressEventArgs>(extractor_Extracting);
   extractor.ExtractionFinished += new EventHandler<EventArgs>(extractor_ExtractionFinished);
   extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extractor_FileExtractionStarted);
   extractor.FileExtractionFinished += new EventHandler<FileInfoEventArgs>(extractor_FileExtractionFinished);
   extractor.PreserveDirectoryStructure = true;
   string Separator = "";
   if (DirectoryName[DirectoryName.Length - 1] != Char.Parse(@"\")) Separator = @"\";
   AddToLog($"Extracted Archive to {DirectoryName}{Separator}{ArchName} from source {FileName}");
   extractor.BeginExtractArchive(DirectoryName + Separator + ArchName);
 }
Ejemplo n.º 9
0
 public static void ExtractArchive(string archFileName, string extractFolder)
 {
     SevenZipExtractor.SetLibraryPath(LibraryPath);
     var extractor = new SevenZipExtractor(archFileName);
     extractor.BeginExtractArchive(extractFolder);
 }