I agree with rowe_newsgroups, XML is how I would do it.
Using XML isn't hard either. I use the code below to do exactly this.
Private Sub LoadSettings()
Dim dsSettings as new Dataset
Dim dtSettings as Datatable
Dim SettingsPath As String = Application.StartupPath & "\" &
My.Settings.ServerSettingsFile
dsSettings.DataSetName = "ServerSettings"
If IO.File.Exists(SettingsPath) Then
dsSettings.ReadXml(SettingsPath)
dtSettings = dsSettings.Tables("HardDriveSettings")
Else
Dim dcSN As New DataColumn 'Server Name
Dim dcDTM As New DataColumn 'Drive to monitor.
Dim dcFSTH As New DataColumn 'Free Space Threshhold in GBs
Dim drSettings As DataRow
dcSN.ColumnName = "ServerName"
dcSN.DataType = GetType(System.String)
dcDTM.ColumnName = "DriveLeter"
dcDTM.DataType = GetType(System.String)
dcFSTH.ColumnName = "FreeSpaceThreshHold"
dcFSTH.DataType = GetType(System.Int32)
dtSettings = New DataTable
dtSettings.TableName = "HardDriveSettings"
dtSettings.Columns.Add(dcSN)
dtSettings.Columns.Add(dcDTM)
dtSettings.Columns.Add(dcFSTH)
drSettings = dtSettings.NewRow
drSettings(0) = "stc-dc"
drSettings(1) = "D:"
drSettings(2) = 15
dtSettings.Rows.Add(drSettings)
End If
End Sub
In the above example I created a settings file for a program which
monitors hard drive space on production servers. Using XML to store the
list of servers to be monitored along with the dirve letter and free
space setting.
In your case after you load the settings using dsSettings.ReadXml(Path)
and after your users make a change you would then call
dsSettings.WriteXml(Path) to write the change to disk.
Izzy
rowe_newsgroups wrote:
Another option is to use XML files. Check out the XML document object
model. Be warned that this approach is more difficult to set up and
requires more code to use. Just throwing in my 2 cents :-)
Thanks,
Seth Rowe
IdleBrain wrote:
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.
Use SaveSetting("ApplicationName", "FolderName", "City", "Chicago") to
store after user selects a different city.
Use txtboxCityName.text = GetSetting("ApplicationName", "FolderName",
"City", "DefaultValue") when you load the form to fill up the textbox
Hope it helps.