[C#] Ini Library

Started by G_G, March 06, 2010, 10:01:20 am

Previous topic - Next topic

G_G

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)

Library Source Download (This is the source to the library)
Download (30 KB)

Code Example Project (This is a windows form project that has example code in it)
Download (65 KB)


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)

fugibo

...isn't there already a native API for this?

G_G

I dunno. There most likely is and I just did it the long way around.

Ryex

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
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

I'm pretty sure you have an INI writer/reader implementation in C#. You have Win32 API calls for that after all. O_o
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.