ChoIniDocument
This is the continuation of previous articles about handling INI section. In this section, I’ll show you how you can read all the available INI section inside a INI document.. For a sample INI file below
;This is a test INI file.
[PRODUCT]
VERSION=1.002 ;Version Comment
COMPANY=NAG Groups LLC
ADDRESS=10 River Road, \
Orlando, \
FL 100230.
[SOFTWARE]
OS1=Windows
ENVIRONMENT=PRODUCTION
Reading all the INI sections can be done as below
using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\TestIni1.ini"))
{
foreach (ChoIniSectionNode iniSectionNode in iniDocument.Sections)
{
Console.WriteLine(String.Format("Key-Values for {0} Section...", iniSectionNode.Name));
foreach (KeyValuePair<string, string> keyValue in iniSectionNode.KeyValues)
Console.WriteLine("{0} = {1}", keyValue.Key, keyValue.Value);
}
}