Beispiel #1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(outPutPath))
            {
                String password = passwordTextBox.Text;

                StatusRichTextBox.Text += "[" + DateTime.Now.ToString("dd.MM.yyyy - HH.mm.ss") + "] " + "Extracting window opened." + Environment.NewLine;

                if (archivePath.EndsWith(".arc"))
                {
                    StatusProgressBar.Style = ProgressBarStyle.Marquee;
                    ARC arcExtract = new ARC(Application.StartupPath + @"\resources\arc\Arc.exe");
                    arcExtract.ProcessFinished += new EventHandler(extr_ExtractionFinished);
                    arcExtract.ExtractArchive(this.archivePath, this.outPutPath);
                }
                else if (archivePath.EndsWith(".paq8o"))
                {
                    StatusProgressBar.Style = ProgressBarStyle.Marquee;
                    PAQ8O paqExtract = new PAQ8O(Application.StartupPath + @"\resources\paq\paq8o.exe");
                    paqExtract.ProcessFinished += new EventHandler(extr_ExtractionFinished);
                    paqExtract.ExtractArchive(this.archivePath, this.outPutPath);
                }
                else
                {
                    StatusProgressBar.Style = ProgressBarStyle.Blocks;
                    if (!passwordTextBox.Enabled && String.IsNullOrEmpty(password))
                    {
                        extractor = new SevenZipExtractor(archivePath);
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(password))
                        {
                            MessageBox.Show("You need to type password!");
                            return;
                        }
                        else
                        {
                            extractor = new SevenZipExtractor(archivePath, password);
                        }
                    }
                    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(outPutPath);
                }
            }
            else
            {
                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    outPutPath = folderBrowserDialog1.SelectedPath;
                    outPutTextBox.Text = outPutPath;
                }
            }
        }