private void Wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { ZipExtract ex = new ZipExtract(); ex.Extract("AutoIT.zip"); Execute.Start(); }
internal static void ReadZipContent(ZipExtract form, String fileNameAndPath, out bool isPasswordProtected) { DataGridView zipContentDataGridView = form.zipContentDataGridView; zipContentDataGridView.DataSource = GetZipContentList(fileNameAndPath, out isPasswordProtected); zipContentDataGridView.Sort(zipContentDataGridView.Columns[1], ListSortDirection.Ascending); }
internal static void ShowZipExtract(Form form, String fileNameAndPath) { ZipExtract zipExtract = new ZipExtract { Owner = form }; zipExtract.InitializeForm(fileNameAndPath); zipExtract.ShowDialog(form); }
private void UpdateBot_Click(object sender, RoutedEventArgs e) { if (Worker.IsRunning) { StartBot_Click(sender, e); } BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (o, ev) => { var version = "v0.0"; if (File.Exists("MyBot.run.version.au3")) { var au3 = File.ReadAllText("MyBot.run.version.au3"); version = Regex.Match(au3, "\\$g_sBotVersion = \"(.+)\"").Groups[0].Value.Replace("$g_sBotVersion =", "").Replace("\"", "").Trim().Split(' ')[0]; } var wc = new WebClient(); wc.Headers.Add("User-Agent", "MyBot.Supporter.UpdateChecker"); var api = JsonConvert.DeserializeObject <GithubAPI>(wc.DownloadString("https://api.github.com/repos/MyBotRun/MyBot/releases/latest")); var apiver = api.TagName.Replace("MBR_", ""); var compare = string.Compare(version, apiver, true); if (compare < 0) { MessageBox.Show("Start downloading latest version..."); wc.Headers.Add("User-Agent", "MyBot.Supporter.UpdateChecker"); wc.DownloadFile(api.Assets[0].BrowserDownloadUrl, api.Assets[0].Name); ZipExtract ex = new ZipExtract(); ex.Extract(api.Assets[0].Name); MessageBox.Show("Job done!"); } else if (compare > 0) { MessageBox.Show("You are using future version of MyBot!"); } else { MessageBox.Show("You are using latest version of MyBot!"); } wc.Dispose(); }; var frame = new DispatcherFrame(); worker.RunWorkerCompleted += (s2, args) => { frame.Continue = false; }; worker.RunWorkerAsync(); Dispatcher.PushFrame(frame); }
internal static void ExtractZipContent(Form1 form1, ZipExtract form, String fileNameAndPath, bool isPasswordProtected) { ToolStripStatusLabel toolStripStatusLabel = form1.toolStripStatusLabel; ToolStripProgressBar toolStripProgressBar = form1.toolStripProgressBar; DataGridView zipContentDataGridView = form.zipContentDataGridView; try { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog { Description = LanguageUtil.GetCurrentLanguageString("folderBrowserDialogDescription", className), RootFolder = Environment.SpecialFolder.Desktop, SelectedPath = FileUtil.GetInitialFolder(form1) }; if (folderBrowserDialog.ShowDialog(form) != DialogResult.OK) { return; } toolStripProgressBar.Value = 0; toolStripProgressBar.Visible = true; toolStripProgressBar.PerformStep(); String selectedFilesRegExpression = SerializeSelectedFilesToExport(zipContentDataGridView.SelectedRows); toolStripProgressBar.PerformStep(); FastZip zipFile = new FastZip(); if (isPasswordProtected) { WindowManager.ShowNameEntry(form); if (String.IsNullOrEmpty(form.newObjectName)) { toolStripProgressBar.Visible = false; return; } ZipFile testZip = null; bool testResult; try { testZip = new ZipFile(fileNameAndPath) { Password = form.newObjectName }; testResult = testZip.TestArchive(true, TestStrategy.FindFirstError, form1.Zip_Errors); } finally { if (testZip != null) { testZip.Close(); } } if (!testResult) { toolStripProgressBar.Visible = false; return; } zipFile.Password = form.newObjectName; } toolStripProgressBar.PerformStep(); FastZip.ConfirmOverwriteDelegate overDelegate = (PromptOverwrite); zipFile.ExtractZip(fileNameAndPath, folderBrowserDialog.SelectedPath, FastZip.Overwrite.Prompt, overDelegate, selectedFilesRegExpression, String.Empty, true); toolStripProgressBar.PerformStep(); toolStripProgressBar.Visible = false; String success = LanguageUtil.GetCurrentLanguageString("ExtractSuccess", className); toolStripStatusLabel.Text = success; WindowManager.ShowInfoBox(form, success); } catch (Exception exception) { toolStripProgressBar.Visible = false; WindowManager.ShowErrorBox(form, exception.Message, exception); } }