The method I use for my program is to keep my configuration values in a class that uses a DataTable in a DataSet to store values. When I want to save it, I use DataSet.WriteXML() to whatever filename the user wants.
My current use is pretty simple (one DataTable with key, value columns) but it easily expands to multiple related DataTables with specific columns for various information. The DataSet handles the file io.
Then it's a breeze to read back in with DataSet.ReadXML().
An advantage of this method over serializing classes is that it is much easier to handle files saved from a previous version of your program. You can set a value in the table for the version of the program used to save it, so your newer version will know the older file won't have any values added in the newer version - and it can set them appropriately to update the file version.
If you add new features to a class (values, methods) it's serialized file will be different than earlier versions - not sure how easy it would be to handle those older files.
Here is a simple example class.
Used like this, makes a file like this:
To create a new one:
Dim UIcfg As UIsettings = New UIsettings("TestSettings.cfg")
UIcfg.setGeneralValue("Version", "1.0.0")
UIcfg.setGeneralValue("Author", "Bobs YourUncle")
UIcfg.setFieldValues("FirstName", "Left", "1")
UIcfg.setFieldValues("LastName", "Right", "1")
UIcfg.setFieldValues("ShoeSize", "Left", "2")
UIcfg.setFieldValues("ShoeColor", "Left", "3")
UIcfg.Save()
To get values from it:
Dim value As String = ""
Dim values As String = ""
value = UIcfg.getGeneralValue("Author")
values = UIcfg.getFieldValues("FirstName")
Code is so much easier than trying to explain a concept. :-)
Ron