public void Rename()
        {
            // Type
            var workingDirectory = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System_IO_FileInfo_Rename"));
            workingDirectory.EnsureDirectoryExists();
            workingDirectory.Clear();

            var @this = new FileInfo(Path.Combine(workingDirectory.FullName, "Examples_System_IO_FileInfo_Rename.txt"));
            var @thisNewFile = new FileInfo(Path.Combine(workingDirectory.FullName, "Examples_System_IO_FileInfo_Rename2.cs"));
            bool result1 = @thisNewFile.Exists;

            // Intialization
            using (FileStream stream = @this.Create())
            {
            }

            // Examples
            @this.Rename("Examples_System_IO_FileInfo_Rename2.cs");

            // Unit Test
            @thisNewFile = new FileInfo(Path.Combine(workingDirectory.FullName, "Examples_System_IO_FileInfo_Rename2.cs"));
            bool result2 = @thisNewFile.Exists;

            Assert.IsFalse(result1);
            Assert.IsTrue(result2);
        }
        public void RenameFile()
        {
            String path = @"c:\temp\setup.txt";
            FileInfo file = new FileInfo(path);
            Assert.True(file.Exists);

            FileInfo newFile = file.Rename("abc.txt");
            Assert.False(file.Exists);
            Assert.True(newFile.Exists);
        }
 public void CanRenameAFile()
 {
     var file = new FileInfo(@"C:\temp\Test.txt");
     file.Rename("Test2.txt");
 }
        /// <summary>
        /// Event fired when the Save buttons is pressed.
        /// Saves all the current scoring settings
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string contents;

            // ========================================== Scoring Common
            // Get current file contents
            using (Stream Str = ScoringCommonFile.OpenRead())
            using (StreamReader Rdr = new StreamReader(Str))
                contents = Rdr.ReadToEnd();

            // Player
            contents = Regex.Replace(contents, Scores["SCORE_KILL"][1], "SCORE_KILL = " + KillScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_TEAMKILL"][1], "SCORE_TEAMKILL = " + TeamKillScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_SUICIDE"][1], "SCORE_SUICIDE = " + SuicideScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_REVIVE"][1], "SCORE_REVIVE = " + ReviveScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_TEAMDAMAGE"][1], "SCORE_TEAMDAMAGE = " + TeamDamage.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_TEAMVEHICLEDAMAGE"][1], "SCORE_TEAMVEHICLEDAMAGE = " + TeamVehicleDamage.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_DESTROYREMOTECONTROLLED"][1], "SCORE_DESTROYREMOTECONTROLLED = " + DestroyEnemyAsset.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_KILLASSIST_DRIVER"][1], "SCORE_KILLASSIST_DRIVER = " + DriverKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_KILLASSIST_PASSENGER"][1], "SCORE_KILLASSIST_PASSENGER = " + PassangerKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_KILLASSIST_TARGETER"][1], "SCORE_KILLASSIST_TARGETER = " + TargeterKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_KILLASSIST_DAMAGE"][1], "SCORE_KILLASSIST_DAMAGE = " + DamageAssist.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_HEAL"][1], "SCORE_HEAL = " + GiveHealth.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_GIVEAMMO"][1], "SCORE_GIVEAMMO = " + GiveAmmo.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["SCORE_REPAIR"][1], "SCORE_REPAIR = " + VehicleRepair.Value, RegexOptions.Multiline);
            // Bots
            contents = Regex.Replace(contents, Scores["AI_SCORE_KILL"][1], "AI_SCORE_KILL = " + AiKillScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_TEAMKILL"][1], "AI_SCORE_TEAMKILL = " + AiTeamKillScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_SUICIDE"][1], "AI_SCORE_SUICIDE = " + AiSuicideScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_REVIVE"][1], "AI_SCORE_REVIVE = " + AiReviveScore.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_TEAMDAMAGE"][1], "AI_SCORE_TEAMDAMAGE = " + AiTeamDamage.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_TEAMVEHICLEDAMAGE"][1], "AI_SCORE_TEAMVEHICLEDAMAGE = " + AiTeamVehicleDamage.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_DESTROYREMOTECONTROLLED"][1], "AI_SCORE_DESTROYREMOTECONTROLLED = " + AiDestroyEnemyAsset.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_KILLASSIST_DRIVER"][1], "AI_SCORE_KILLASSIST_DRIVER = " + AiDriverKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_KILLASSIST_PASSENGER"][1], "AI_SCORE_KILLASSIST_PASSENGER = " + AiPassangerKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_KILLASSIST_TARGETER"][1], "AI_SCORE_KILLASSIST_TARGETER = " + AiTargeterKA.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_KILLASSIST_DAMAGE"][1], "AI_SCORE_KILLASSIST_DAMAGE = " + AiDamageAssist.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_HEAL"][1], "AI_SCORE_HEAL = " + AiGiveHealth.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_GIVEAMMO"][1], "AI_SCORE_GIVEAMMO = " + AiGiveAmmo.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["AI_SCORE_REPAIR"][1], "AI_SCORE_REPAIR = " + AiVehicleRepair.Value, RegexOptions.Multiline);
            // Replenish
            contents = Regex.Replace(contents, Scores["REPAIR_POINT_LIMIT"][1], "REPAIR_POINT_LIMIT = " + RepairPointLimit.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["HEAL_POINT_LIMIT"][1], "HEAL_POINT_LIMIT = " + HealPointLimit.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["GIVEAMMO_POINT_LIMIT"][1], "GIVEAMMO_POINT_LIMIT = " + AmmoPointLimit.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["TEAMDAMAGE_POINT_LIMIT"][1], "TEAMDAMAGE_POINT_LIMIT = " + TeamDamageLimit.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["TEAMVEHICLEDAMAGE_POINT_LIMIT"][1], "TEAMVEHICLEDAMAGE_POINT_LIMIT = " + TeamVDamageLimit.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, Scores["REPLENISH_POINT_MIN_INTERVAL"][1], "REPLENISH_POINT_MIN_INTERVAL = " + ReplenishInterval.Value, RegexOptions.Multiline);

            // Save File
            using (Stream Str = ScoringCommonFile.Open(FileMode.Truncate, FileAccess.Write))
            using (StreamWriter Wtr = new StreamWriter(Str))
            {
                Wtr.Write(contents);
                Wtr.Flush();
            }

            // ========================================== Scoring Conquest
            // Get curent file contents
            using (Stream Str = ScoringConqFile.OpenRead())
            using (StreamReader Rdr = new StreamReader(Str))
                contents = Rdr.ReadToEnd();

            // Do Replacements
            contents = Regex.Replace(contents, ConqScores["SCORE_CAPTURE"][1], "SCORE_CAPTURE = " + ConqFlagCapture.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["SCORE_CAPTUREASSIST"][1], "SCORE_CAPTUREASSIST = " + ConqFlagCaptureAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["SCORE_NEUTRALIZE"][1], "SCORE_NEUTRALIZE = " + ConqFlagNeutralize.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["SCORE_NEUTRALIZEASSIST"][1], "SCORE_NEUTRALIZEASSIST = " + ConqFlagNeutralizeAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["SCORE_DEFEND"][1], "SCORE_DEFEND = " + ConqDefendFlag.Value, RegexOptions.Multiline);
            // Bots
            contents = Regex.Replace(contents, ConqScores["AI_SCORE_CAPTURE"][1], "AI_SCORE_CAPTURE = " + AiCqFlagCapture.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["AI_SCORE_CAPTUREASSIST"][1], "AI_SCORE_CAPTUREASSIST = " + AiCqFlagCaptureAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["AI_SCORE_NEUTRALIZE"][1], "AI_SCORE_NEUTRALIZE = " + AiCqFlagNeutralize.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["AI_SCORE_NEUTRALIZEASSIST"][1], "AI_SCORE_NEUTRALIZEASSIST = " + AiCqFlagNeutralizeAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, ConqScores["AI_SCORE_DEFEND"][1], "AI_SCORE_DEFEND = " + AiCqDefendFlag.Value, RegexOptions.Multiline);

            // Save File
            using (Stream Str = ScoringConqFile.Open(FileMode.Truncate, FileAccess.Write))
            using (StreamWriter Wtr = new StreamWriter(Str))
            {
                Wtr.Write(contents);
                Wtr.Flush();
            }

            // ========================================== Scoring Coop
            // Get current file contents
            using (Stream Str = ScoringCoopFile.OpenRead())
            using (StreamReader Rdr = new StreamReader(Str))
                contents = Rdr.ReadToEnd();

            // Do Replacements
            contents = Regex.Replace(contents, CoopScores["SCORE_CAPTURE"][1], "SCORE_CAPTURE = " + CoopFlagCapture.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["SCORE_CAPTUREASSIST"][1], "SCORE_CAPTUREASSIST = " + CoopFlagCaptureAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["SCORE_NEUTRALIZE"][1], "SCORE_NEUTRALIZE = " + CoopFlagNeutralize.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["SCORE_NEUTRALIZEASSIST"][1], "SCORE_NEUTRALIZEASSIST = " + CoopFlagNeutralizeAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["SCORE_DEFEND"][1], "SCORE_DEFEND = " + CoopDefendFlag.Value, RegexOptions.Multiline);
            // Bots
            contents = Regex.Replace(contents, CoopScores["AI_SCORE_CAPTURE"][1], "AI_SCORE_CAPTURE = " + AiCoopFlagCapture.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["AI_SCORE_CAPTUREASSIST"][1], "AI_SCORE_CAPTUREASSIST = " + AiCoopFlagCaptureAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["AI_SCORE_NEUTRALIZE"][1], "AI_SCORE_NEUTRALIZE = " + AiCoopFlagNeutralize.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["AI_SCORE_NEUTRALIZEASSIST"][1], "AI_SCORE_NEUTRALIZEASSIST = " + AiCoopFlagNeutralizeAsst.Value, RegexOptions.Multiline);
            contents = Regex.Replace(contents, CoopScores["AI_SCORE_DEFEND"][1], "AI_SCORE_DEFEND = " + AiCoopDefendFlag.Value, RegexOptions.Multiline);

            // Save File
            using (Stream Str = ScoringCoopFile.Open(FileMode.Truncate, FileAccess.Write))
            using (StreamWriter Wtr = new StreamWriter(Str))
            {
                Wtr.Write(contents);
                Wtr.Flush();
            }

            // Remove the ServerSettings.con file as that screws with the replenish scores
            FileInfo file = new FileInfo(Path.Combine(MainForm.SelectedMod.RootPath, "Settings", "ScoreManagerSetup.con"));
            if (file.Exists)
                file.Rename("ScoreManagerSetup.con.bak");

            // Close this form
            this.Close();
        }