/// <summary> /// 导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnConfirm_Click(object sender, EventArgs e) { txtLoc.Text = txtLoc.Text.Trim(); if (txtLoc.Text == "") { TXMessageBoxExtensions.Info("提示:请选择导出文件的存储路径!"); txtLoc.Focus(); return; } string destFilename = MyCommon.GetFileShortName(txtLoc.Text); string destFolder = Path.GetDirectoryName(txtLoc.Text); if (!Directory.Exists(destFolder)) { TXMessageBoxExtensions.Info("存储的路径不存在!"); return; } /// <summary> /// 导出功能涉及的文件临时存放目录 /// </summary> string tempFullName = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\ERM\\OutDataTemp"; try { btnCancel.Enabled = false; btnConfirm.Enabled = false; btnExplorer.Enabled = false; if (System.IO.Directory.Exists(tempFullName)) { MyCommon.DeleteFilesAndFolders(tempFullName); } Directory.CreateDirectory(tempFullName); // MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); //MyCommon.DeleteAndCreateEmptyDirectory(tempFullName); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_GdList\\"); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_FileList\\"); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\"); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\ODOC\\"); //原文 MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\PDF\\"); //原文的PDF文件 MyCommon.DeleteAndCreateEmptyDirectory(tempFullName + "\\" + TheNode.Name + "\\T_CellAndEFile\\MPDF\\"); //文件级电子文件,带章 int sumCount = 0; GetNodesCount(TheNode, ref sumCount); GetChildToFileCount(TheNode, ref sumCount); progressBar1.Maximum = sumCount; ParentToFile(TheNode, tempFullName + "\\" + TheNode.Name); ChildToFile(TheNode, tempFullName + "\\" + TheNode.Name); lblTitle.Text = @"正在压缩导出数据...."; progressBar1.Value = progressBar1.Maximum / 2; Application.DoEvents(); //Common.ZipFile zip = new Common.ZipFile(tempFullName + "\\", txtLoc.Text); //zip.StartZip(); SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll"); SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor(); tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip; tmp.CompressDirectory(tempFullName + "\\", txtLoc.Text); System.Threading.Thread.Sleep(1000); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);//删除文件夹 lblTitle.Text = @"导出完成!"; Application.DoEvents(); this.DialogResult = DialogResult.OK; btnCancel.Enabled = true; btnConfirm.Enabled = true; btnExplorer.Enabled = true; } catch (Exception ex) { TXMessageBoxExtensions.Info(ex.Message); this.DialogResult = DialogResult.Cancel; MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false);//删除文件夹 } }