public static void Restore(int errorFlag) { try { var targetDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//DarkSoulsII"; const string sourceDirectory = @"Backup"; Replacer.Copy(sourceDirectory, targetDirectory); if (errorFlag.Equals(0)) { SystemSounds.Asterisk.Play(); } } catch { if (errorFlag.Equals(1)) { const bool flag = true; var error = new Error(flag); if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//DarkSoulsII")) { Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//DarkSoulsII"); } SystemSounds.Hand.Play(); error.ShowDialog(); } } }
public static void Backup(int errorFlag) { var flag = true; try { var sourceDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//DarkSoulsII"; const string targetDirectory = @"Backup"; Replacer.Copy(sourceDirectory, targetDirectory); if (errorFlag.Equals(0)) { SystemSounds.Asterisk.Play(); } } catch { flag = false; if (errorFlag.Equals(1)) { var error = new Error(false); if (Directory.Exists("Backup")) { Directory.Delete("Backup"); } SystemSounds.Hand.Play(); error.ShowDialog(); } } try { var wins = File.ReadAllText("wins.txt"); var winsInt = int.Parse(wins); winsInt++; wins = winsInt.ToString(); if (flag.Equals(true)) { System.IO.File.WriteAllText("wins.txt", wins); } } catch { System.IO.File.WriteAllText("wins.txt", "0"); } }