Cinchoo – Multiline INI values, Part 5

ChoIniDocument

In this section, I’ll show you how you can store and read multiline values from Ini file. According to INI specification, multiline INI values are supported. In the below sample, ADDRESS section value is specified as multiline value. \ char is used to break the line in the unquote-ted value.

;This is a test INI file.

[PRODUCT]
VERSION=1.002 ;Version Comment
COMPANY=NAG Groups LLC
ADDRESS=10 River Road, \
        Orlando, \
        FL 100230.

Alternatively you can give multi-line value in quotes as below

;This is a test INI file.

[PRODUCT]
VERSION=1.002 ;Version Comment
COMPANY=NAG Groups LLC
ADDRESS="10 River Road,
        Orlando,
        FL 100230."

Try and see the value returned from the below statement…

using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\TestIni1.ini"))
{
    Console.Writeline(iniDocument["PRODUCT"]["ADDRESS"]);
}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s