public static void loadXml() { TranslatingProgressHandler.setTranslatedMessage("LoadingGameXmls"); supress_duplicate_game_warnings = false; xml = new GameXmlFiles(); model.Clear(); if (xml.Entries.Count > 0) { TranslatingProgressHandler.setTranslatedMessage("LoadingGamesData"); foreach (GameSaveInfo.Game game in xml.Entries) { foreach (GameVersion version in game.Versions) { try { GameEntry entry; if (version is CustomGameVersion) { entry = new CustomGameEntry(version as CustomGameVersion); } else { entry = new GameEntry(version); } addGame(entry); } catch (Exception e) { TranslatingMessageHandler.SendException(e); } } } } }
private void checkExceptions(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { TranslatingMessageHandler.SendException(e.Error); } }
private static void purgeRoots(object sender, DoWorkEventArgs e) { // if (TranslatingRequestHandler.Request(RequestType.Question, "PurgeConfirmation").Cancelled) { // e.Cancel = true; // return; // } ProgressHandler.saveMessage(); e.Result = false; foreach (GameEntry game in (System.Collections.IEnumerable)e.Argument) { TranslatingProgressHandler.setTranslatedMessage("Purging", game.Title); try { if (game.purge(false)) { e.Result = true; } else { break; } } catch (Exception ex) { TranslatingMessageHandler.SendError("PurgeError", ex, game.id.ToString()); } } StaticNotifyPropertyChanged("HasUnsubmittedGames"); ProgressHandler.restoreMessage(); }
protected override GameXmlFile ReadFile(FileInfo path) { bool keep_trying = true; while (keep_trying) { try { if (path.Name == "custom.xml") { this.custom = new CustomGameXmlFile(path); return this.custom; } else { GameXmlFile file = new GameXmlFile(path); return file; } } catch (VersionNotSupportedException ex) { if (ex.FileVersion == null || !GameSaveInfo.Converters.AConverter.CanConvert(ex.FileVersion)) { string version_string; if (ex.FileVersion == null) version_string = Strings.GetLabelString("UnknownVersion"); else version_string = ex.FileVersion.ToString(); if (!TranslatingRequestHandler.Request(MVC.Communication.RequestType.Question, "GameDataObsoleteDelete", path.Name, version_string).Cancelled) { path.Delete(); } keep_trying = false; } } catch (XmlException ex) { TranslatingMessageHandler.SendError("XMLFormatError", ex, path.FullName); keep_trying = handleCorruptedFile(path); } catch (NotSupportedException ex) { TranslatingMessageHandler.SendError("XMLFormatError", ex, path.FullName); keep_trying = handleCorruptedFile(path); } } return null; }
protected void forwardExceptions(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { TranslatingMessageHandler.SendException(e.Error); } }
protected virtual void doWork(object sender, DoWorkEventArgs e) { ProgressHandler.state = ProgressState.Indeterminate; if (!initialized) { TranslatingProgressHandler.setTranslatedMessage("LoadingSettings"); if (!settings.IsReady) { initialized = false; TranslatingMessageHandler.SendError("CriticalSettingsFailure"); return; } Core.locations.setup(); settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged); monitor = new Monitor.Monitor(); TranslatingProgressHandler.setTranslatedMessage("ValidatingBackupPath"); if (settings.IsBackupPathSet && (!PermissionsHelper.isReadable(settings.backup_path) || !PermissionsHelper.isWritable(settings.backup_path))) settings.clearBackupPath(); if (!locations.ready) return; //task = new Task.TaskHandler(); initialized = true; } //ProgressHandler.progress_state = ProgressState.Normal; }
private void saveBtn_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog(); save.DefaultExt = "txt"; save.Filter = Strings.GetLabelString("TxtFileDescriptionPlural") + "|*.txt|" + Strings.GetLabelString("AllFileDescriptionPlural") + "|*"; save.Title = Strings.GetLabelString("SaveReportQuestion"); if (AAnalyzer.LastSavePath == null) { save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } else { save.InitialDirectory = AAnalyzer.LastSavePath; } save.FileName = analyzer.game.Name + ".txt"; if (save.ShowDialog(this.GetIWin32Window()) != System.Windows.Forms.DialogResult.Cancel) { AAnalyzer.LastSavePath = Path.GetDirectoryName(save.FileName); try { StreamWriter writer = File.CreateText(save.FileName); writer.Write(reportTxt.Text); writer.Close(); saved = true; } catch (Exception ex) { TranslatingMessageHandler.SendError("WriteError", ex, save.FileName); } } }
void worker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { if (e.Error != null) { TranslatingMessageHandler.SendException(e.Error); worker.RunWorkerAsync(); } NotifyPropertyChanged("Status"); NotifyPropertyChanged("Active"); }
public void start() { while (!Core.settings.IsBackupPathSet && !backuppathwarned) { RequestReply reply = RequestHandler.Request(RequestType.BackupFolder, false); if (reply.Cancelled) { TranslatingMessageHandler.SendWarning("MonitorNeedsBackupPath"); backuppathwarned = true; //throw new TranslateableException("BackupPathNotSet"); } } this.EnableRaisingEvents = true; }
public bool CheckBackuptPathForMonitor() { if (!Core.settings.IsBackupPathSet) { RequestReply reply = RequestHandler.Request(RequestType.BackupFolder, false); if (reply.Cancelled) { TranslatingMessageHandler.SendWarning("MonitorNeedsBackupPath"); return(false); //throw new TranslateableException("BackupPathNotSet"); } } return(true); }
public static void beginRestore(AViewWindow parent, List <Archive> archives) { string extrasave = ProgressHandler.message; ProgressHandler.saveMessage(); parent.hideInterface(); if (archives.Count > 1 && !TranslatingRequestHandler.Request(RequestType.Question, "RestoreMultipleArchives").Cancelled) { Restore.RestoreProgramHandler.use_defaults = true; } foreach (Archive archive in archives) { if (Restore.RestoreProgramHandler.overall_stop) { break; } Restore.RestoreWindow restore = new Restore.RestoreWindow(archive, parent); restore.ShowDialog(); switch (restore.Result) { case RestoreResult.Success: Core.redetect_games = true; break; case RestoreResult.Cancel: case RestoreResult.Failed: case RestoreResult.ElevationFailed: break; } } Restore.RestoreProgramHandler.use_defaults = false; Restore.RestoreProgramHandler.overall_stop = false; // Restore.RestoreProgramHandler.default_user = null; if (Restore.RestoreProgramHandler.unsuccesfull_restores.Count > 0) { StringBuilder fail_list = new StringBuilder(); foreach (string failed in Restore.RestoreProgramHandler.unsuccesfull_restores) { fail_list.AppendLine(failed); } TranslatingMessageHandler.SendError("RestoreSomeFailed", fail_list.ToString()); } parent.showInterface(); ProgressHandler.message = extrasave; }
void BackupProgramHandler_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // Make this check for things errors so it can clean up after itself if (output_path == null) { return; } foreach (FileInfo delete_me in new DirectoryInfo(output_path).GetFiles("~*.tmp")) { try { delete_me.Delete(); } catch (Exception ex) { TranslatingMessageHandler.SendError("DeleteError", ex, delete_me.Name); } } }
private static void addGame(GameEntry game) { bool dont_add = false; if (model.containsId(game.id)) { GameEntry current = model.get(game.id); string file_used = null; if (game.SourceFile == "new.xml") { file_used = game.SourceFile; model.Remove(current); } else if (current.SourceFile == "new.xml") { file_used = current.SourceFile; } else { file_used = current.SourceFile; dont_add = true; if (!supress_duplicate_game_warnings) { supress_duplicate_game_warnings = TranslatingMessageHandler.SendWarning("DuplicateGame", true, game.id.ToString(), game.SourceFile, current.SourceFile, file_used) >= ResponseType.Suppressed; } } } if (game.id.OS == "PS1") { // GameVersion psp_game = // GameXML psp_game = game_profile; // psp_game = new GameXML(new GameID(psp_game.id.name, "PSP", psp_game.id.region), psp_game.xml); // createGameObject(psp_game); } if (!dont_add) { model.AddWithSort(game); } }
public static void DetectBackups() { ProgressHandler.saveMessage(); model.Clear(); if (!Core.settings.IsBackupPathSet) { return; } ProgressHandler.state = ProgressState.Normal; string path = null; path = Core.settings.backup_path; FileInfo[] read_us = new DirectoryInfo(path).GetFiles("*.gb7"); ProgressHandler.value = 0; if (read_us.Length > 0) { ProgressHandler.max = read_us.Length; TranslatingProgressHandler.setTranslatedMessage("LoadingArchives", ProgressHandler.value.ToString(), read_us.Length.ToString()); foreach (FileInfo read_me in read_us) { ProgressHandler.value++; try { Archive add_me = new Archive(read_me); if (add_me != null) { model.AddWithSort(add_me); } } catch (Exception e) { TranslatingMessageHandler.SendException(e); } } } ProgressHandler.state = ProgressState.None; ProgressHandler.value = 0; ProgressHandler.restoreMessage(); }
private void beginRestoration() { if (flipper.IsActiveControl(selectFilesGroup)) { if (files.SelectedItems.Count == 0) { TranslatingMessageHandler.SendError("RestoreNoFiles"); return; } } TranslationHelpers.translate(this, "RestoringFile", restore.archive.id.ToString()); restoreButton.Visibility = System.Windows.Visibility.Collapsed; choosePathButton.Visibility = System.Windows.Visibility.Collapsed; selectFilesButton.Visibility = System.Windows.Visibility.Collapsed; otherUserButton.Visibility = System.Windows.Visibility.Collapsed; cancelButton.Text = Strings.GetLabelString("Stop"); flipper.SwitchControl(ProgressBox); if (Restore.RestoreProgramHandler.use_defaults && userCombo.SelectedItem != null) { //RestoreProgramHandler.default_user = (string)userCombo.SelectedItem; } if (files != null) { foreach (SelectFile file in files) { if (file.IsSelected) { restore.specifyFileToRestore(file.name); } } } restore.restoreBackup((LocationPath)pathCombo.SelectedItem, (string)userCombo.SelectedItem, restoreComplete); }
//public static void addShield(Button button) { // button.FlatStyle = FlatStyle.System; // SendMessage(button.Handle, BCM_SETSHIELD, 0, 0xFFFFFFFF); //} public static ElevationResult elevation(string app_name, string new_args, bool wait_for_exit) { StringBuilder arg_string = new StringBuilder(); if (new_args != null) { arg_string.Append(new_args); } string[] args = Environment.GetCommandLineArgs(); for (int j = 1; j < args.Length; j++) { if (args[j].Contains(" ")) { arg_string.Append(" \"" + args[j] + "\""); } else { arg_string.Append(" " + args[j]); } } if (!Core.settings.SuppressElevationWarnings) { ResponseType response = ResponseType.OK; if (Environment.OSVersion.Version < new Version(6, 0)) { response = TranslatingMessageHandler.SendWarning("ElevationXPWarning", true); } if (response >= ResponseType.Suppressed) { Core.settings.SuppressElevationWarnings = true; } } return(runExe(app_name, arg_string.ToString(), true, wait_for_exit)); }
public bool Detect() { // detect_override = rnd.Next(0, 2) == 0; List <DetectedLocationPathHolder> interim = new List <DetectedLocationPathHolder>(); List <ALocation> locations = AllLocations; if (this.id.Name == "HalfLife2Deathmatch") { System.Console.Out.Write(""); } foreach (ALocation location in locations) { // This skips if a location is marked as only being for a specific version of an OS if (location.OnlyFor != Core.locations.platform_version && location.OnlyFor != null) { continue; } if (location.GetType() == typeof(LocationParent)) { // This checks all the locations that are based on other games LocationParent game = location as LocationParent; if (Games.Contains(game.game)) { GameEntry parent_game = Games.Get(game.game); // If the game hasn't been processed in the GamesHandler yetm it won't yield useful information, so we force it to process here if (!parent_game.DetectionAttempted) { parent_game.Detect(); } foreach (DetectedLocationPathHolder check_me in parent_game.DetectedLocations) { string path = location.modifyPath(check_me.FullDirPath); interim.AddRange(Core.locations.interpretPath(path)); } } else { TranslatingMessageHandler.SendError("ParentGameDoesntExist", game.game.ToString()); } } else { // This checks all the registry locations // This checks all the shortcuts // This parses each location supplied by the XML file //if(title.StartsWith("Postal 2")) //if(id.platform== GamePlatform.PS1) interim.AddRange(Core.locations.getPaths(location)); } } DetectedLocations = new Location.DetectedLocations(); foreach (DetectedLocationPathHolder check_me in interim) { if (version.Identifiers.Count == 0) { DetectedLocations.Add(check_me); continue; } foreach (Identifier identifier in version.Identifiers) { if (identifier.FindMatching(check_me.FullDirPath).Count > 0) { DetectedLocations.Add(check_me); break; } } } _detected_paths_string = new StringBuilder(); foreach (DetectedLocationPathHolder location in DetectedLocations) { _detected_paths_string.AppendLine(location.FullDirPath); } NotifyPropertyChanged("IsDetected"); NotifyPropertyChanged("IsMonitored"); DetectionAttempted = true; return(IsDetected); }
void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { MonitorFile file; while (!worker.CancellationPending) { NotifyPropertyChanged("Active"); NotifyPropertyChanged("Status"); if (QueueCount == 0) { // No new files? Take a nap. try { Thread.Sleep(100); } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } continue; } lock (FileQueue) { file = FileQueue.Dequeue(); } if (!file.Path.Game.IsMonitored) { continue; } FileInfo fi = new FileInfo(Path.Combine(file.root, file.path)); GameID game = file.Path.Game.id; switch (file.change_type) { case System.IO.WatcherChangeTypes.Changed: case System.IO.WatcherChangeTypes.Created: case System.IO.WatcherChangeTypes.Renamed: if (!fi.Exists) { continue; } List <DetectedFile> these_files = file.Path.Game.GetSavesMatching(file.full_path); if (these_files.Count == 0) { continue; } foreach (DetectedFile this_file in these_files) { _status = game.Name + " updating " + Path.Combine(this_file.Path, this_file.Name); NotifyPropertyChanged("Status"); if (this_file.FullDirPath == null) { continue; } Archive archive = Archives.GetArchive(game, this_file); try { if (archive == null) { if (this_file.owner == null) { archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file)); } else { archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file)); } Archives.Add(archive); } //monitorNotifier.ShowBalloonTip(10, "Safety Will Robinson", "Trying to archive " + file.path, ToolTipIcon.Info); MessageHandler.suppress_messages = true; List <DetectedFile> temp_list = new List <DetectedFile>(); temp_list.Add(this_file); archive.backup(temp_list, false, true); } catch { //monitorNotifier.ShowBalloonTip(10,"Danger Will Robinson","Error while trying to archive " + file.path,ToolTipIcon.Error); // If something goes wrong during backup, it's probable the file copy. // Reinsert the file to the end of the queue, then move on to the next one. if (!FileQueue.Contains(file)) { FileQueue.Enqueue(file); } } finally { MessageHandler.suppress_messages = false; } } break; } if (worker.CancellationPending) { e.Cancel = true; } _status = null; } NotifyPropertyChanged("Status"); NotifyPropertyChanged("Active"); }
void BackupProgramHandler_DoWork(object sender, DoWorkEventArgs e) { if (Core.settings.IsBackupPathSet || archive_name_override != null) { if (archive_name_override != null) { output_path = Path.GetDirectoryName(archive_name_override); } else { output_path = Core.settings.backup_path; } IList <GameEntry> games; if (back_these_up != null && back_these_up.Count > 0) { games = back_these_up; } else { if (Games.detected_games_count == 0) { Games.detectGames(); } games = Games.DetectedGames.Items; } if (games.Count > 0) { ProgressHandler.value = 1; ProgressHandler.max = games.Count; TranslatingProgressHandler.setTranslatedMessage("GamesToBeBackedUpCount", games.Count.ToString()); foreach (GameEntry game in games) { if (CancellationPending) { return; } //if(archive_name_override!=null) //all_users_archive = new ArchiveHandler(new FileInfo(archive_name_override),game.id); if (games.Count == 1) { TranslatingProgressHandler.setTranslatedMessage("BackingUpSingleGame", game.Title); } else { TranslatingProgressHandler.setTranslatedMessage("BackingUpMultipleGames", game.Title, ProgressHandler.value.ToString(), games.Count.ToString()); } List <DetectedFile> files; if (only_these_files != null && only_these_files.Count > 0) { files = only_these_files; } else { files = game.Saves.Flatten(); ; } Archive override_archive = null; try { DictionaryList <Archive, DetectedFile> backup_files = new DictionaryList <Archive, DetectedFile>(); foreach (DetectedFile file in files) { ArchiveID archive_id; Archive archive; if (CancellationPending) { return; } archive_id = new ArchiveID(game.id, file); if (archive_name_override != null) { if (override_archive == null) { file.Type = null; } override_archive = new Archive(new FileInfo(archive_name_override), new ArchiveID(game.id, file)); archive = override_archive; } else { if (Archives.Get(archive_id) == null) { Archives.Add(new Archive(output_path, new ArchiveID(game.id, file))); } archive = Archives.Get(archive_id); } backup_files.Add(archive, file); } if (CancellationPending) { return; } foreach (KeyValuePair <Archive, List <DetectedFile> > backup_file in backup_files) { if (override_archive == null) { backup_file.Key.backup(backup_file.Value, false, false); } else { backup_file.Key.backup(backup_file.Value, true, false); } } } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } finally { ProgressHandler.value++; } } } else { TranslatingMessageHandler.SendError("NothingToBackup"); } } else { TranslatingMessageHandler.SendError("BackupPathNotSet"); } }
protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e) { base.doWork(sender, e); path_candidates = new SimpleModel <LocationPath>(); user_candidates = new SimpleModel <string>(); ProgressHandler.state = ProgressState.Indeterminate; try { if (archive == null) { } } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } if (ArgArchives.Count > 0) { archive = new Archive(new FileInfo(ArgArchives.Dequeue())); } if (archive == null) { throw new TranslateableException("NoRestoreFileSelected"); } TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration"); if (!archive.Exists) { throw new TranslateableException("FileNotFound", archive.ArchivePath); } GameID selected_game = archive.id.Game; string backup_owner = archive.id.Owner; string archive_type = archive.id.Type; try { game_data = Games.detectGame(selected_game); } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } NotifyPropertyChanged("GameNotDetected"); if (game_data != null) { // This adds hypothetical locations foreach (LocationPath location in game_data.Locations.Paths) { if (game_data.DetectionRequired) { break; } filterPathCandidates(location); } // This add already found locations foreach (DetectedLocationPathHolder location in game_data.DetectedLocations) { location.IsSelected = true; switch (location.EV) { case EnvironmentVariable.ProgramFiles: case EnvironmentVariable.ProgramFilesX86: // This adds a fake VirtualStore folder, just in case if (Core.locations.uac_enabled) { DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner); temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3))); temp.EV = EnvironmentVariable.LocalAppData; addPathCandidate(temp); } addPathCandidate(location); break; default: addPathCandidate(location); break; } } //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) { // foreach (string drive in Core.locations.ps.GetDriveCandidates()) { // DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null); // addPathCandidate(loc); // } //} } if (archive.id.OriginalEV != EnvironmentVariable.None && archive.id.OriginalRelativePath != null) { LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath); filterPathCandidates(path); } if (archive.id.OriginalLocation != null) { DetectedLocations locs = Core.locations.interpretPath(archive.id.OriginalLocation); DetectedLocationPathHolder loc = locs.getMostAccurateLocation(); if (loc != null) { addPathCandidate(loc); } } if (path_candidates.Count == 1) { multiple_paths = false; NotifyPropertyChanged("only_path"); } else if (path_candidates.Count > 1) { multiple_paths = true; } else { throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString()); } }
private void add(string file, bool disable_versioning) { FileInfo TempFile = new FileInfo(TempFileName); if (TempFile.Exists) { TempFile.Delete(); } if (this.Exists) { ArchiveFile.CopyTo(TempFileName); File.SetAttributes(TempFileName, FileAttributes.Hidden); } zipper.StartInfo.Arguments = compress_switches + " \"" + TempFileName + "\" \"" + file + "\\*\""; run7z(false); File.SetAttributes(TempFileName, FileAttributes.Hidden); // This here's the versioning stuff. Since it's here, it's universal. // This handles versioning copies if (!disable_versioning && Core.settings.VersioningEnabled) { if (Core.settings.VersioningMax != 0) { DateTime right_now = DateTime.Now; FileInfo original_file = new FileInfo(file); if (original_file.Exists) { if (right_now.Ticks - original_file.CreationTime.Ticks > Core.settings.VersioningTicks) { string new_path = Path.Combine(original_file.DirectoryName, Path.GetFileNameWithoutExtension(original_file.FullName) + "@" + right_now.ToString().Replace('/', '-').Replace(':', '-') + Path.GetExtension(original_file.FullName)); try { File.Move(file, new_path); //File.SetCreationTime(temp_file_name,right_now); } catch (Exception ex) { throw new TranslateableException("RevisionCopyError", ex, original_file.FullName); } } else { // This is if it hasn't been long enough for a new file } } else { // This shouldn't really be an error, as it just means that it's a new archive //MessageHandler.SendError("Where'd That Come From?","The file " + file_name + " can't be found."); } } else { //this is if the Settings for versioning are f****d up } FileInfo[] count_us = new DirectoryInfo(Path.GetDirectoryName(file)).GetFiles( Path.GetFileNameWithoutExtension(file) + "@*"); if (count_us.Length > Core.settings.VersioningMax) { Array.Sort(count_us, new MASGAU.Comparers.FileInfoComparer(true)); for (long i = Core.settings.VersioningMax; i < count_us.Length; i++) { try { (count_us[i] as FileInfo).Delete(); } catch (Exception ex) { TranslatingMessageHandler.SendError("DeleteError", ex, (count_us[i] as FileInfo).Name); } } } } else { // This is if versioning is disabled, or something } if (Exists) { ArchiveFile.Delete(); } TempFile.MoveTo(ArchiveFile.FullName); File.SetAttributes(ArchiveFile.FullName, FileAttributes.Normal); }
// This helps determin wether this is the first time the archive has been backed up to // it's so we can bypass the date checks as they will not be accurate anymore public void backup(ICollection <DetectedFile> files, bool disable_versioning, bool disable_date_check) { prepTemp(); if (Exists) { if (!canWrite(ArchiveFile)) { throw new TranslateableException("WriteDenied", ArchiveFile.FullName); } } else { if (!canWrite(ArchiveFile.Directory)) { throw new TranslateableException("WriteDenied", ArchiveFile.DirectoryName); } // If this is the first time writing to the archive, we create the identifying XML XmlDocument write_me = new XmlDocument(); if (File.Exists(Path.Combine(TempFolder, "masgau.xml"))) { File.Delete(Path.Combine(TempFolder, "masgau.xml")); } XmlTextWriter write_here = new XmlTextWriter(Path.Combine(TempFolder, "masgau.xml"), System.Text.Encoding.UTF8); write_here.Formatting = Formatting.Indented; write_here.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); write_here.WriteStartElement("masgau_archive"); write_here.Close(); write_me.Load(Path.Combine(TempFolder, "masgau.xml")); //XmlNode root = write_me.DocumentElement; id.AddElements(write_me); FileStream this_file = new FileStream(Path.Combine(TempFolder, "masgau.xml"), FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite); write_me.Save(this_file); write_here.Close(); this_file.Close(); } bool files_added = false; foreach (DetectedFile file in files) { // Copies the particular file to a relative path inside the temp folder FileInfo source; FileInfo destination; if (file.Path == "" || file.Path == null) { source = new FileInfo(Path.Combine(file.AbsoluteRoot, file.Name)); destination = new FileInfo(Path.Combine(TempFolder, file.Name)); } else { source = new FileInfo(Path.Combine(file.AbsoluteRoot, file.Path, file.Name)); destination = new FileInfo(Path.Combine(TempFolder, file.Path, file.Name)); } if (!source.Exists) { continue; } DateTime file_write_time = source.LastWriteTime; int time_comparison = LastModified.CompareTo(source.LastWriteTime); if (Core.settings.IgnoreDateCheck || disable_date_check || time_comparison <= 0) { try { if (!destination.Directory.Exists) { destination.Directory.Create(); } } catch (Exception e) { TranslatingMessageHandler.SendError("CreateError", e, destination.DirectoryName); continue; } if (source.Exists) { try { source.CopyTo(destination.FullName, true); } catch (Exception e) { TranslatingMessageHandler.SendError("CopyError", e, source.FullName, destination.FullName); continue; } } else { TranslatingMessageHandler.SendError("FileToCopyNotFound", source.FullName); continue; } if (destination.Exists) { try { if ((destination.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { File.SetAttributes(destination.FullName, FileAttributes.Normal); } } catch (Exception e) { TranslatingMessageHandler.SendError("PermissionChangeError", e, destination.FullName); continue; } } else { TranslatingMessageHandler.SendError("FileCopiedNotFound", source.FullName, destination.FullName); continue; } files_added = true; } //file_date = new FileInfo(file_name).LastWriteTime; } if (files_added) { add(TempFolder, disable_versioning); } purgeTemp(); }