/// <summary>ZIPファイルをインストール</summary> /// <param name="entry">エントリ</param> /// <param name="zipFile">ZIPファイル名</param> /// <param name="history">エントリ(履歴)</param> /// <param name="encStr">エンコーディング</param> public static void InstallZip(Entry entry, string zipFile, Entry history, string encStr) { if (Program.HaveBackup) { // バックアップ済み。 } else { if (Directory.Exists(entry.InstallDir)) { // インストール先を指定 Program.InstallDirectory = entry.InstallDir; // バックアップ先を指定 string guid = Guid.NewGuid().ToString(); if (entry.InstallDir[entry.InstallDir.Length - 1] == '\\') { Program.BackupDirectory = entry.InstallDir.Substring( 0, entry.InstallDir.Length - 1) + "_" + guid; } else { Program.BackupDirectory = entry.InstallDir + "_" + guid; } // バックアップする。 Program.HaveBackup = true; FileSystem.CopyDirectory(entry.InstallDir, BackupDirectory, UIOption.OnlyErrorDialogs, UICancelOption.DoNothing); } } // ZIPファイル内のコンテンツを削除 Program.DeleteZipContents(zipFile, history); // 環境変数に対応 string InsDir = PubCmnFunction. BuiltStringIntoEnvironmentVariable(entry.InstallDir); // 解凍 // 解凍部品 UnZipper uz = new UnZipper(); // 選択基準なしで string[] exts = null; Zipper.SelectionDelegate scd = null; //if (this.txtExt.Enabled) //{ // exts = this.txtExt.Text.Split(','); // scd = SelectionCriteriaDlgt2; //} // 解凍時、上書き制御 uz.ExtractProgress = Program.MyExtractProgressEventHandler; // 解凍(1)デリゲートでフィルタ uz.ExtractFileFromZip( Program.OrgCurrentDirectory + Program.TempZipFileName, PubCmnFunction.BuiltStringIntoEnvironmentVariable(entry.InstallDir), scd, exts, ExtractExistingFileAction.OverwriteSilently, Encoding.GetEncoding(encStr), ""); // メッセージ Program.OutPutMessage(string.Format( GetMessage.GetMessageDescription("I0011"), zipFile), LogLevel.InfoLog); // 解凍先のファイルのパスを抽出 string header = "extract file "; StringReader srZipContents = new StringReader(uz.StatusMSG); List<string> zipContents = new List<string>(); string tempContentFile = srZipContents.ReadLine(); while (tempContentFile != null && tempContentFile.Trim() != "") { if (tempContentFile.IndexOf(header) == 0) { // 解凍先のファイルのパスを抽出([- 3] は[...]の分) zipContents.Add(tempContentFile.Substring(header.Length, tempContentFile.Length - header.Length - 3)); } // 次へ tempContentFile = srZipContents.ReadLine(); } // 解凍先のファイルのパスを保存する(次回の削除処理に使用)。 entry.HttpZipContents[zipFile] = zipContents.ToArray(); }
/// <summary>解凍処理</summary> private void btnDecomp_Click(object sender, EventArgs e) { try { // チェック処理 this.CheckComp_DeComp(); // 解凍部品 UnZipper uz = new UnZipper(); // 選択基準 string[] exts = null; Zipper.SelectionDelegate scd = null; if (this.txtExt.Enabled) { exts = this.txtExt.Text.Split(','); scd = Program.SelectionCriteriaDlgt2; } // 解凍時、上書き制御 uz.ExtractProgress = Program.MyExtractProgressEventHandler; // 解凍(1)デリゲートでフィルタ uz.ExtractFileFromZip( this.txtFile.Text, this.txtFolder.Text, scd, exts, (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), this.txtPass.Text); //// 解凍(2):selectionCriteriaStringでフィルタ //string selectionCriteriaString = ""; //if (exts != null) //{ // foreach (string ext in exts) // { // if (selectionCriteriaString == "") // { // selectionCriteriaString = "name != *." + ext; // } // else // { // selectionCriteriaString += " and name != *." + ext; // } // } //} //uz.ExtractFileFromZip( // this.txtFile.Text, // this.txtFolder.Text, // selectionCriteriaString, // (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, // Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), // this.txtPass.Text); //MessageBox.Show(uz.StatusMSG, "サマリ", // MessageBoxButtons.OK, MessageBoxIcon.Information); //CustMsgBox custMsgBox = new CustMsgBox("サマリ(解凍)", uz.StatusMSG, SystemIcons.Information); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0003"), uz.StatusMSG, SystemIcons.Information); custMsgBox.ShowDialog(); } catch(Exception ex) { //MessageBox.Show(ex.Message, "エラーが発生しました。", MessageBoxButtons.OK, MessageBoxIcon.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(ex.Message, ResourceMgr.GetString("E0001"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }