Chaos Project

Game Development => Sea of Code => Development Tools => Topic started by: G_G on March 06, 2010, 10:01:20 am

Title: [C#] Ini Library
Post by: G_G on March 06, 2010, 10:01:20 am
Ini Library



About
The Ini Library is a dll file that easily lets you read and write to ini files. Its an open source library and is for use for any non-commercial/commercial project. I know its normally easy to read from an ini anyways but I wanted to make it a bit simpler.


How To Use
This is to be used with C# so I'm not sure if it'll work with any other language.

First add a reference to your project. Browse to the IniLib and add it.
Now in the top of your code be sure you include
using IniLib;


Okay so lets say we have an ini file that looks like this.
[Name]
First=Bob
Last=Gary

We want to read from that data so this is the code we would use.
Ini ini = new Ini(@"C:\name.ini");
MessageBox.Show(ini.Read(section, key));

So we would replace section with Name and if we wanted it to print our first name we would replace key with First.
MessageBox.Show(ini.Read("Name", "First"));


Writing to an ini file is just as easy. First call our ini.
Ini ini = new Ini(@"C:\name.ini");

Call it by using ini.Write
ini.Write(section, key, value);

So we're gonna replace our first and last name to George Lopez.
ini.Write("Name", "First", "George");
ini.Write("Name", "Last", "Lopez");


Its a very simple to use library and its helped and my laziness.


Downloads
Original Library Download (This is if you just want the IniLib)
Download (1.8 KB) (http://decisive-games.com/ggp/IniLibrbary.zip)

Library Source Download (This is the source to the library)
Download (30 KB) (http://decisive-games.com/ggp/IniLib.zip)

Code Example Project (This is a windows form project that has example code in it)
Download (65 KB) (http://decisive-games.com/ggp/IniTest.zip)


Notes
It is recommended you know some C# before using.
This was made because I am lazy and I wanted a simple way of reading and writing to ini files.


Credits
game_guy ~ This guy made it though credit isn't needed. I really made it because I was lazy/bored one day and I ended up using it for my own projects. So have fun! (This could have been made by anyone with a little bit of searching)
Title: Re: [C#] Ini Library
Post by: fugibo on March 06, 2010, 10:03:10 am
...isn't there already a native API for this?
Title: Re: [C#] Ini Library
Post by: G_G on March 06, 2010, 10:30:12 am
I dunno. There most likely is and I just did it the long way around.
Title: Re: [C#] Ini Library
Post by: Ryex on March 06, 2010, 10:57:40 am
Quote from: fugo ad te, pikachu! on March 06, 2010, 10:03:10 am
...isn't there already a native API for this?


I never found one in my searches
Title: Re: [C#] Ini Library
Post by: Blizzard on March 08, 2010, 02:49:21 am
I'm pretty sure you have an INI writer/reader implementation in C#. You have Win32 API calls for that after all. O_o