In this section, I’ll talk about another important feature Cinchoo framework provides in reading INI file is that the support of Hierarchical INI sections. It gives the flexibility of organizing the INI sections in hierarchical way. An INI section can have another INI subsection in it. Here is how you can do it using Cinchoo framework,
;This is a test nested INI file. ;To test its functionality. [CORPORATIONS] [CORPORATIONS/FINANCE] CORP1=JP Morgan Chase COPR2=Morgan Stantley [CORPORATIONS/TECHNOLOGY] CORP1=Google COPR2=Apple
In the above sample INI file, the Hierarchical sections are given with ‘/’ separator. ‘CORPORATIONS’ section contains ‘FINANCE’ and ‘TECHNOLOGY’ subsections. There are couple ways, we can access them programmatically
using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\NestedIniSection.ini"))
{
Console.WriteLine(iniDocument["CORPORATIONS/TECHNOLOGY"]["CORP1"]);
Console.WriteLine(iniDocument["CORPORATIONS"].GetSection("TECHNOLOGY")["CORP1"]);
}
November 14th, 2012 at 5:17 AM
Cool tool,
My only nag: you probably meant “Morgan Stanley”
But perhaps not because of the lawyers
November 14th, 2012 at 7:36 AM
Typo mistake. Corrected. Thanks for your comment.
January 21st, 2013 at 7:57 AM
Hi,
I have a problem with this framework.
If I add to reference Cinchoo and add namespace -
using Cinchoo.Core.Ini;
Visual studio show error
Error 1 The type or namespace name ‘Cinchoo’ could not be found (are you missing a using directive or an assembly reference?)
Where is problem ?
January 22nd, 2013 at 2:00 PM
Your project needs to be build with “.NET framework 4″ instead of “.NET framework 4 Client Profile”. Please go to project properties->Application tab, choose the ‘Target Framework’ as ‘.NET framework 4′. Let me know if that helps.
January 23rd, 2013 at 1:29 AM
Hi, you have right, thank you very much.
Thank you for help