Yes. This may not be the most efficient way to read from a ini file but it is a pretty good solution that is easy to maintain.
You can use a XML file to store your settings. Use a DataSet to read from it. Consider a simple sample file, config.ini. It has three parameters base_path, update_path and output_file. These will map to columns in the settings datatable.
// add error handling
DataSet ds = new DataSet();
ds.ReadXml('config.ini', XmlReadMode.Auto);
DataTable table = ds.Tables['settings'];
DataRow row = table.Rows[0];
string baseFolder = (string)row['base_path'];
string updateFolder = (string)row['update_path'];
string outputFileName = (string)row['output_file'];
You can of course use XmlReader, XmlDocument etc to create and maintain more complex ini files. But this is a quick way to maintain a simple property set.
Share with