Skip to content

Getting started with IniFile

martinusso edited this page Dec 12, 2014 · 2 revisions

Getting Started with IniFile

A Simple Example

Let’s take an example INI file.

[Company]
Name=Ini Corporation, Inc
Type=Public
Employees=12,345

Below is a C# example piece of code that describes how to read the values from the INI file from the file above:

using Ini.Net;

var iniFile = new IniFile("config_filename.ini");

string companyName = iniFile.ReadString("Company", "Name");
string companyType = iniFile.ReadString("Company", "Type");
int companyEmployees = iniFile.ReadInteger("Company", "Employees");

And now we will to write some values in the INI file:

string companyWebsite = "www.ini.net";
iniFile.WriteString("Company", "Website", companyWebsite);

bool isMultinational = false;
iniFile.WriteBoolean("Company", "Multinational", isMultinational);

Clone this wiki locally