Hi @Marc Menzel ,
Maybe you can use the code below to export/import settings.
Private Sub export_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles export.Click
Dim sDialog As New SaveFileDialog()
sDialog.DefaultExt = ".AppSettings"
sDialog.Filter = "Application Settings (*.AppSettings)|*AppSettings"
If sDialog.ShowDialog() = DialogResult.OK Then
Using sWriter As New StreamWriter(sDialog.FileName)
For Each setting As Configuration.SettingsPropertyValue In My.Settings.PropertyValues
sWriter.WriteLine(setting.Name & "," & setting.PropertyValue.ToString())
Next
End Using
My.Settings.Save()
MessageBox.Show("Settings has been saved to the specified file", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub import_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles import.Click
Dim oDialog As New OpenFileDialog
oDialog.Filter = "Application Settings (*.AppSettings)|*AppSettings"
If oDialog.ShowDialog() = DialogResult.OK Then
Using sReader As New StreamReader(oDialog.FileName)
While sReader.Peek() > 0
Dim input = sReader.ReadLine()
' Split comma delimited data ( SettingName,SettingValue )
Dim dataSplit = input.Split(CChar(","))
' Setting Value
My.Settings(dataSplit(0)) = dataSplit(1)
End While
End Using
My.Settings.Save()
MessageBox.Show("Import of settings successfull", "Import", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.