NSoft.NFramework.Nini.Ini.IniSection.Set C# (CSharp) Method

Set() public method

public Set ( ) : void
return void
        public void Set() {
            Set(null);
        }

Same methods

IniSection::Set ( string comment ) : void
IniSection::Set ( string key, string value, string comment = null ) : void

Usage Example

示例#1
0
        public void SaveAsMysqlStyle()
        {
            string     filePath = "Save.ini";
            FileStream stream   = new FileStream(filePath, FileMode.Create);

            // Create a new document and save to stream
            IniDocument doc = new IniDocument();

            doc.FileType = IniFileType.MysqlStyle;
            IniSection section = new IniSection("Pets");

            section.Set("my comment");
            section.Set("dog", "rover");
            doc.Sections.Add(section);
            doc.Save(stream);
            stream.Close();

            StringWriter writer = new StringWriter();

            writer.WriteLine("[Pets]");
            writer.WriteLine("# my comment");
            writer.WriteLine("dog = rover");

            StreamReader reader = new StreamReader(filePath);

            Assert.AreEqual(writer.ToString(), reader.ReadToEnd());
            reader.Close();

            IniDocument iniDoc = new IniDocument();

            iniDoc.FileType = IniFileType.MysqlStyle;
            iniDoc.Load(filePath);

            File.Delete(filePath);
        }
All Usage Examples Of NSoft.NFramework.Nini.Ini.IniSection::Set