Click here to Skip to main content
Click here to Skip to main content
Go to top

Cinchoo - Hierarchical INI sections

, 7 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Defining and using Hierarchical INI sections

Introduction  

Cinchoo is the application framework for .NET. One of the feature it exposes is an API to read and write INI file. This article reveals in particular of reading and storing Hierarchical INI sections. It gives an opportunities to contain INI sections within another INI section.  

Please download latest Cinchoo binary from here. 

How to use 

For a sample INI file below 

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

[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(@"Sample.ini"))
{
    Console.WriteLine(iniDocument["CORPORATIONS/TECHNOLOGY"]["CORP1"]);
    Console.WriteLine(iniDocument["CORPORATIONS"].GetSection("TECHNOLOGY")["CORP1"]); 
}  

Sample project is attached for download. Try for yourself. Thanks. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cinchoo

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Jan 2013
Article Copyright 2013 by Cinchoo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid