This project is read-only.
The LibINI API has been designed to be very streamlined and easy to use.

Example 1: Creating and Writing Settings to an INI file.
LibINI.IniFile MySettings = new LibINI.IniFile("settings.ini");
MySettings.CreateSection("Author Info");
MySettings["Author Info"].CreateEntry("Name");
MySettings["Author Info"]["Name"].Value = "John Doe";
MySettings["Author Info"].CreateEntry("Homepage");
MySettings["Author Info"]["Homepage"].Value = "http://example.com/";
MySettings.Write();
// Will write the following:
// [Author Info]
// Name=John Doe
// Homepage=http://example.com

Example 2: Reading Settings from an INI file.
//Lets assume we are reading the INI file created in Example 1.
LibINI.IniFile MySettings = new LibINI.IniFile("settings.ini");
MySettings.Load();
string Name = MySettings["Author Info"]["Name"].Value;
string Homepage = MySettings["Author Info"]["Homepage"].Value;

Example 3: Reading an INI file and adding to it.
//Lets assume we are reading the INI file created in Example 1.
IniFile MySettings = new IniFile("settings.ini");
MySettings.Load();
string Name = MySettings["Author Info"]["Name"].Value;
string Homepage = MySettings["Author Info"]["Homepage"].Value;
string Email = "Name@example.com";
if (MySettings["Author Info"].ContainsEntry("Email") == false)
{
    MySettings["Author Info"].CreateEntry("Email");
    MySettings["Author Info"]["Email"].Value = Email;
}
else
{
    Email = MySettings["Author Info"]["Email"].Value;
}

LibINI Members:

Last edited Dec 2, 2006 at 7:23 AM by WShelley, version 6

Comments

No comments yet.