
Introduction
In the line of software development many times I have come across situations where I needed some kind of functionality to read, write and modify basic configuration options for my application. Here is a basic solution.
The ConfigManager helps developers to the same task in a very easy manner.
ConfigManager class has the following members:
ConfigManager() - Constructor, creates application.config file as the default configuration file
ConfigManager(string) - Constructor, creates a configuration file by given parameter which is filename.
bool AddValue(string key,object value) - Adds a value by key. The key is unique.
bool RemoveValue(string key,object value) - Removes a value by key.
object GetValue(string key,object default) - Returns a value by key or the default. Creates the entry if it doesn't exists.
ArrayList GetValues(string key,object default) - Returns an ArrayList of values.
bool UpdateValue(string key,object default) - Updates a value by key.
How to use the ConfigManager
Here is a simple example of how to use the ConfigManager's GetValues()
ConfigManager c = new ConfigManager();
ArrayList List = c.GetValues();
foreach(ConfigManagerKeyValue Item in List) {
Console.WriteLine("{0,10} is {1,10}",Item.Key , Item.Value);
}
Have fun C#ing :)
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here