/// <summary> /// 解压Z文件 /// </summary> /// <param name="ObsDataSource"></param> /// <param name="destDir"></param> /// <param name="delSourse"></param> private void DecomressZFile(string source, string destDir, bool delSourse) { if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } string[] files = Directory.GetFiles(source); if (this.ProgressBar != null) { this.ProgressBar.InitProcess(files.Length); } foreach (var item in files) { if (IsCancelProcessing) { break; } try { CompressUtil.Decompres(item, destDir); } catch (Exception ex) { string msg = "解压 Z 文件出错了:" + ex.Message + "\r\n"; ShowInfo(msg); if (!ignoreError) { if (FormUtil.ShowYesNoMessageBox(msg + "是否继续?") == System.Windows.Forms.DialogResult.No) { break; } } } //try{ // if (delSourse) { System.Threading.Thread.Sleep(100); File.Delete(key); } //} //catch (Exception ex) //{ // string msg = "删除 Z文件出错了:" + ex.Message + key+ "\r\n"; // ShowInfo(msg); // if (!ignoreError) // if (FormUtil.ShowYesNoMessageBox(msg + "是否继续?") // == System.Windows.Forms.DialogResult.No) // break; //} string info = "解压Z文件 " + item; ShowInfo("总进度 " + (allCountProcess) + "/" + allCount + " " + info); PerformStep(); } }
private void button_decompress_Click(object sender, EventArgs e) { string compressedFilePath = this.textBox_sourseZip.Text; string destDir = this.textBox_destDir.Text; string pass = GetPassword(); CompressUtil.Decompres(compressedFilePath, destDir, pass); FormUtil.ShowIfOpenDirMessageBox(destDir); }
private void button_mulit_decompress_Click(object sender, EventArgs e) { string sourseDir = this.textBox_source_dir.Text; string destDir = this.textBox_dest_dir.Text; string pass = GetPassword(); string[] files = Directory.GetFiles(sourseDir); bool deleSourse = this.checkBox_deleSouse.Checked; progressBar1.Maximum = files.Length; progressBar1.Minimum = 1; progressBar1.Step = 1; progressBar1.Value = progressBar1.Minimum; foreach (var item in files) { try { CompressUtil.Decompres(item, destDir, pass, deleSourse); } catch (Exception ex) { if (!checkBox_ignoreError.Checked) { if (FormUtil.ShowYesNoMessageBox("出错了:" + ex.Message + "\r\n" + "是否继续?") == System.Windows.Forms.DialogResult.No) { break; } } } progressBar1.PerformStep(); progressBar1.Refresh(); } FormUtil.ShowIfOpenDirMessageBox(destDir); }