/// <summary> /// 生成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(tb_version.Text)) { MessageBox.Show("版本号不能为空!"); return; } if (String.IsNullOrEmpty(tb_description.Text)) { MessageBox.Show("描述不能为空!"); return; } if (fileList.Count == 0) { MessageBox.Show("至少选择一个文件!"); return; } string errorMsg = ""; string templatePath = System.Environment.CurrentDirectory + "//templates//upgrade.tar.gz"; // 将templates先删除 ZipHelper.DeleteDirectory(System.Environment.CurrentDirectory + "//update"); // 清空完了创建 Directory.CreateDirectory(System.Environment.CurrentDirectory + "//update"); // 解压文件 ZipHelper.UnzipTgz(templatePath, System.Environment.CurrentDirectory + "//update"); // 遍历文件列表 foreach (var file in fileList) { string targetPath = System.Environment.CurrentDirectory + "/update"; switch (file.FileType) { case "iot-one": targetPath += "/classes/iot-one/BOOT-INF"; break; case "iot-business-dcom": targetPath += "/classes/iot-business-dcom/BOOT-INF"; break; } ZipHelper.CopyFile(file.FilePath, targetPath + "/" + file.FileTarget, file.FileName); } // 写入版本信息 // 写入说明文件 // 打包 ZipHelper.CreatTarGzArchive(System.Environment.CurrentDirectory, "update"); if (File.Exists(System.Environment.CurrentDirectory + "/update.tar.gz")) { if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string foldPath = dialog.SelectedPath; DirectoryInfo theFolder = new DirectoryInfo(foldPath); File.Copy(System.Environment.CurrentDirectory + "/update.tar.gz", foldPath + "/update" + DateTime.Now.ToString("yyyyMMdd") + ".tar.gz", true); System.Windows.MessageBox.Show("导出成功!"); } } }