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; } } }
private void build_Click(object sender, EventArgs e) { if (filesListView.Items.Count < 0) return; String randomPath = DateTime.Now.Millisecond.ToString(); tempFolder = Path.GetTempPath() + @"Archive (" + DateTime.Now.ToString("dd.MM.yyyy - HH.mm.ss") + @")\"; String type = outputTextBox.Text.Substring(outputTextBox.Text.LastIndexOf(@".") + 1); CheckFolder(); CopyFiles(tempFolder); if (!String.IsNullOrEmpty(outputTextBox.Text)) { StatusRichTextBox.Text += "[" + DateTime.Now.ToString("dd.MM.yyyy - HH.mm.ss") + "] " + "Archiving window opened." + Environment.NewLine; if (cmbFormat.SelectedIndex <= 2) { StatusProgressBar.Style = ProgressBarStyle.Blocks; SevenZipCompressor.SetLibraryPath(Application.StartupPath + @"\resources\7z\7zLib.dll"); SevenZipCompressor cmp = new SevenZipCompressor(); cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing); cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_FileCompressionStarted); cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompressionFinished); cmp.ArchiveFormat = (OutArchiveFormat)Enum.Parse(typeof(OutArchiveFormat), cmbFormat.Text); cmp.CompressionLevel = (CompressionLevel)int.Parse(cmbLevel.Text); cmp.CompressionMethod = (CompressionMethod)Enum.Parse(typeof(CompressionMethod), cmbMethod.Text); if (String.IsNullOrEmpty(passwordTextBox.Text)) cmp.BeginCompressDirectory(tempFolder, outputTextBox.Text); else cmp.BeginCompressDirectory(tempFolder, outputTextBox.Text, passwordTextBox.Text); } else { StatusProgressBar.Style = ProgressBarStyle.Marquee; StatusProgressBar.Value = 1; if (cmbFormat.SelectedIndex == 3) { Classes.Algorithms.Compressing.SevenZip archiver = new Classes.Algorithms.Compressing.SevenZip(Application.StartupPath + @"\resources\7z\7z.exe"); archiver.Add(tempFolder); archiver.ProcessFinished += new EventHandler(cmp_CompressionFinished); archiver.GenerateArchive(outputTextBox.Text); } else if (cmbFormat.SelectedIndex == 4) { PAQ8O archiver = new PAQ8O(Application.StartupPath + @"\resources\paq\paq8o.exe"); archiver.CompressionLevel = cmbLevel.Text; archiver.Add(tempFolder); archiver.ProcessFinished += new EventHandler(cmp_CompressionFinished); archiver.GenerateArchive(outputTextBox.Text); } else if (cmbFormat.SelectedIndex == 5) { ARC archiver = new ARC(Application.StartupPath + @"\resources\arc\Arc.exe"); archiver.CompressionLevel = cmbLevel.Text; archiver.Add(tempFolder.Remove(tempFolder.Length - 1)); archiver.ProcessFinished += new EventHandler(cmp_CompressionFinished); archiver.GenerateArchive(outputTextBox.Text); } else if (cmbFormat.SelectedIndex == 6) { Classes.Algorithms.Compressing.SevenZip archiver = new Classes.Algorithms.Compressing.SevenZip(Application.StartupPath + @"\resources\7z\7z.exe"); archiver.CompressionMethod = cmbMethod.Text; archiver.Password = passwordTextBox.Text; archiver.Add(tempFolder); archiver.ProcessFinished += new EventHandler(cmp_CompressionFinished); archiver.GenerateSFX(outputTextBox.Text); } } } else { Save(); } }