0

in My.Settings i've alot of variables including a 36000 records Datatable and Couple Large Array Lists, now when i call My.Settings.Save() it saves all the variables which takes alot of time and it saves variables that haven't been changed, is there a way make it Save only a Specific Datatable or ArrayList?

My.Setting.Save() 
'but what i want for example is something like
My.Settings.SomeDatatable.Save()
user1570048
  • 880
  • 6
  • 35
  • 69

2 Answers2

0

These settings are stored in an XML file. Since XML files do not store data in a fixed-width record format, there is no way to update a single node in an XML file without rewriting the whole thing. If it is too slow, I would recommend either:

  • Store these settings in multiple XML files, so that you only have to save the applicable file, but not the rest
  • Store the settings in the database where each row can be saved individually without rewriting the whole file

Databases store their data in fixed-width "pages" so that only the modified pages need to be rewritten, rather than the whole file.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
0

What about saving your dataTable not within your Settings. You could make use of DataTable.WriteXml(). this would keep your settings much smaller and you can access them separately!

' save table
DataTable.WriteXml("yourFile.xml")

' load table
Dim newTable As New DataTable
newTable.ReadXml(fileName)

But if there is no other possibility this solution from SLaks will work too

' save table
Dim writer As New StringWriter()
table.WriteXml(writer)
My.MySettings.Default.TableXml = writer.ToString()

' load table
Dim reader As New StringReader(My.MySettings.Default.TableXml)
table.ReadXml(reader)
Community
  • 1
  • 1
Pilgerstorfer Franz
  • 8,303
  • 3
  • 41
  • 54