Nini Library API Reference - http://nini.sourceforge.net/

IniDocument Class

High level INI document access class.

For a list of all members of this type, see IniDocument Members.

System.Object
   Nini.Ini.IniDocument

public class IniDocument

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

Here's an example of accessing the following document, test.ini.

; This is a comment
[My Section]
  key 1 = value 1 ; Comment 1
  key 2 = value 2
[Pets]
  dog = rover
  cat = muffy
            
Here is code for accessing it.
IniDocument doc = new IniDocument ("test.ini");
Console.WriteLine ("Key: " + doc.Get ("My Section", "key 1"));
Console.WriteLine ("Key: " + doc.Get ("Pets", "dog"));
doc.SetSection ("Movies");
doc.SetKey ("Movies", "horror", "Scream");
doc.SetKey ("Movies", "comedy", "Dumb and Dumber");
doc.RemoveSection ("My Section");
doc.RemoveKey ("Pets", "dog");

StringWriter writer = new StringWriter ();
doc.Save (writer);
Console.WriteLine ("New INI document:");
Console.WriteLine (writer.ToString ());
            
This prints out the following response:
Key: value 1
Key: rover
New INI document:
[Pets]
cat = muffy
[Movies]
horror = Scream
comedy = Dumb and Dumber
        

Requirements

Namespace: Nini.Ini

Assembly: Nini (in Nini.dll)

See Also

IniDocument Members | Nini.Ini Namespace