private void UninstallClicked(object sender, RoutedEventArgs e) { if (System.Windows.MessageBoxResult.Yes != System.Windows.MessageBox.Show("Do you really want to uninstall " + Settings.Project + "?", "Are you sure?", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question)) { return; } using (System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog()) { fbd.Description = "Choose the installation directory:"; var result = fbd.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { if (!Uninstaller.DoUninstall(fbd.SelectedPath)) { MessageBox.Show("Couldn't uninstall the software, read the log for more informations!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } else { WriteLog("Software was uninstalled successfuly!"); } } } }
/// <summary> /// Unpacks the files from downloadedfiles /// </summary> /// <param name="downloadedfiles">The locations of the downloaded files</param> async void UnzipInstalledData(string[] downloadedfiles) { bool wasSuccess = true; if (IsUpdate(new FileInfo(downloadedfiles[0]).Directory.FullName)) { _window.WriteLog("Deleting old files from project"); Uninstaller.DoUninstall(new FileInfo(downloadedfiles[0]).Directory.FullName); } _window.WriteLog("Unpack zip archives..."); _window.prog_loading.IsIndeterminate = true; await Task.Run(() => { foreach (string fname in downloadedfiles) { FileInfo fi = new FileInfo(fname); if (fi.Extension == ".zip") { using (FileStream fs = new FileStream(fname, FileMode.Open)) { using (ZipArchive archive = new ZipArchive(fs)) { wasSuccess = ZipArchiveExtensions.ExtractWithSettings(archive, fi.DirectoryName, true); } } File.Delete(fname); } } }); if (!wasSuccess) { Uninstaller.DoUninstall(new FileInfo(downloadedfiles[0]).DirectoryName); _window.WriteLog("There was an error while extracting the archive!"); } else { _window.WriteLog("Installation complete!"); } _window.prog_loading.IsIndeterminate = false; _window.bt_install.IsEnabled = true; }