void getRealModFolders(String modRootPath, ref List <String> output) { try { if (Path.GetDirectoryName(modRootPath).Substring(0, 1) != "@" && Path.GetFileName(modRootPath).Substring(0, 1) != "@") { List <String> modsAndStuff = new List <string>(); DirectoryInfo di = new DirectoryInfo(modRootPath); foreach (DirectoryInfo info in di.GetDirectories()) { if (info.Name.Substring(0, 1) == "@") { output.Add(info.FullName); } else if (info.Name.Equals("userconfig")) { output.Add(info.FullName); } else if (info.Name.Equals("keys") || info.Name.Equals("TeamSpeak 3 Client")) { output.Add(info.FullName); } else { getRealModFolders(info.FullName, ref output); } } } } catch (Exception ex) { ErrorWriter.writeError(ex.Message + " " + ex.StackTrace); } }
void worker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; IArchive compressed = e.Argument as IArchive; DownloadableAddon addon = archiveToAddon[compressed]; string destinationDirectory = this.main.path; int i = 0; foreach (var entry in compressed.Entries) { if (i == 0) { addonToRootPath[addon] = entry.FilePath.Replace("/", ""); } if (!entry.IsDirectory) { try { entry.WriteToDirectory(destinationDirectory, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); List <object> objectsToGive = new List <object>(); objectsToGive.Add(i); objectsToGive.Add(addon); bytesRecievedOfAddon[addon] += entry.Size; } catch (Exception ex) { ErrorWriter.writeError(ex.Message + " " + ex.StackTrace); } //worker.ReportProgress(1, objectsToGive); } i++; } }
void copyFolder(String SourcePath, String DestinationPath) { try { //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath)); } //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true); } } catch (Exception ex) { ErrorWriter.writeError(ex.Message + " " + ex.Source); } }
private void checkForAddons(bool force) { if (listAddons == null) { //System.Windows.MessageBox.Show("Error could not load installed mods"); //listAddons = new System.Windows.Controls.ListBox(); } if (this.didLoadAddons && !force || !this.isCurrentlyRightDirectory) { return; } List <DirectoryInfo> list1; DirectoryInfo directoryInfo1; List <System.Windows.Controls.CheckBox> list2; List <String> allActiveMods; try { list1 = new List <DirectoryInfo>(); directoryInfo1 = new DirectoryInfo(this.path); list2 = new List <System.Windows.Controls.CheckBox>(); allActiveMods = new List <string>(); try { foreach (System.Windows.Controls.CheckBox checkBox in (IEnumerable)this.listAddons.Items) { bool flag = false; foreach (FileSystemInfo fileSystemInfo in directoryInfo1.GetDirectories()) { if (((object)fileSystemInfo.Name).Equals(checkBox.Content)) { flag = true; } } if (!flag) { list2.Add(checkBox); } if (checkBox.IsChecked == true) { allActiveMods.Add(checkBox.Content as String); } } } catch (Exception ex) { ErrorWriter.writeError("first inner exception: " + ex.Message + " " + ex.StackTrace + " " + ex.Source); } try { foreach (object removeItem in list2) { this.listAddons.Items.Remove(removeItem); } foreach (DirectoryInfo directoryInfo2 in directoryInfo1.GetDirectories()) { if (directoryInfo2.Name.Substring(0, 1) == "@" && !this.getAllAddons().Contains(directoryInfo2.Name)) { System.Windows.Controls.CheckBox checkBox = new System.Windows.Controls.CheckBox(); System.Windows.Controls.ContextMenu contextMenu = new System.Windows.Controls.ContextMenu(); System.Windows.Controls.MenuItem menuItem = new System.Windows.Controls.MenuItem(); menuItem.Header = (object)"Löschen"; menuItem.Click += new RoutedEventHandler(this.addonDeleteClick); menuItem.Tag = (object)checkBox; contextMenu.Items.Add((object)menuItem); checkBox.ContextMenu = contextMenu; DownloadableAddon downloadableAddon = ConfigManager.readVersionFileForAddon(this.path, directoryInfo2.Name); checkBox.Tag = (object)downloadableAddon; checkBox.Foreground = (Brush)Brushes.White; checkBox.Content = (object)directoryInfo2.Name; list1.Add(directoryInfo2); this.listAddons.Items.Add((object)checkBox); checkBox.Checked += new RoutedEventHandler(this.c_Checked); checkBox.Unchecked += new RoutedEventHandler(this.c_Unchecked); } } this.activateAddons(allActiveMods); this.didLoadAddons = true; } catch (Exception ex) { ErrorWriter.writeError("second inner exception: " + ex.Message + " " + ex.StackTrace + " " + ex.Source); } } catch (Exception ex) { ErrorWriter.writeError("Error in CheckForAddons() (first)" + ex.Message + " " + ex.StackTrace); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { this.InitializeComponent(); try { this.settings = new ConfigSettings(); if (!ConfigManager.doesConfigExist()) { ConfigManager.writeConfig(this.settings); this.settings = ConfigManager.readConfig(); } else { this.settings = ConfigManager.readConfig(); } if (settings.downloadPath.Equals("http://jpjd.jp.ohost.de/legionlauncher/addons.json")) { settings.downloadPath = "http://www.legion-arma3.de/legionlauncher/addons.json"; } textDownloadPath.Text = settings.downloadPath; try { this.getDownloadableAddons(); } catch (Exception ex) { } this.textPath.Text = settings.path; this.path = this.textPath.Text; this.checkIfExeIsThere(); DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(this.dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 10); dispatcherTimer.Start(); DownloadedSettings downloadedSettings = this.downloader.downloadXML(); if (downloadedSettings != null) { //this.listEvents.SelectedIndex = 0; } else { int num = (int)System.Windows.MessageBox.Show("Konnte keine Verbindung zum Server herstellen. Bitte stellen sie sicher das kein Antivirenprogramm das Programm blockiert."); } this.getFieldOfView(); this.comboServer.SelectedIndex = 0; this.setValuesFromConfig(this.settings); } catch (Exception ex) { int num = (int)System.Windows.MessageBox.Show("Unbekannter Fehler beim starten. Bitte kontaktieren sie www.arama3-legion.de " + ex.Message); } } catch (Exception ex) { ErrorWriter.writeError("Error during loadup: " + ex.Message + " # " + ex.Source + " ### " + ex.InnerException.Message + " # " + ex.InnerException.Source); } }