예제 #1
0
        /// <summary>
        /// Executes the edit and replaces a key in a section in the Oblivion.ini file with a new value.
        /// </summary>
        /// <param name="iniPath">Path to the Oblivion.ini file</param>
        /// <exception cref="ArgumentException">File does not exist</exception>
        public void ExecuteEdit(string iniPath)
        {
            if (!File.Exists(iniPath))
            {
                throw new ArgumentException($"File does not exist: {iniPath}", nameof(iniPath));
            }

            OblivionINI.SetINIValue(iniPath, Section, Name, NewValue);
        }
예제 #2
0
        public void TestOblivionINI_Set()
        {
            const string file     = "oblivion-test-ini-set.ini";
            const string contents = "[General]\nname=Peter Griffin\nage=18 ;very important!";

            File.WriteAllText(file, contents, Encoding.UTF8);

            OblivionINI.SetINIValue(file, "General", "age", "22");

            var newValue = OblivionINI.GetINIValue(file, "General", "age");

            Assert.Equal("22", newValue);
        }