Cinchoo – Accessing INI sections, Part 4


In this section, I’ll walk you over accessing different parts of INI document using ChoIniDocument class

Using Indexer

First and easy way, you can use the indexer to access the key-value information if you have key name in hand. This will search for key-value in the nested INI files as well.

For a sample INI files below,


;This is a test INI file.
;To test its functionality.

VERSION=1.002 ;Version Comment
COMAPNY=NAG Groups LLC ;Company node




Code below shows how to access name-values using indexer

private static void LookupNameValues()
    using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\TestIni1.ini"))
        //Lookup PRODUCT/VERSION

        //Lookup SOFTWARE/OS1 in nested INI file

Using Section Access Methods

You can access INI sections using one of the below overload methods

public ChoIniSectionNode GetSection(string sectionName);
public bool TryGetSection(string sectionName, out ChoIniSectionNode section);

Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s