(.Net) suggestions for creating a configuration file for the program?

I do not necessarily refer to app.configs, but to a user configuration file that will store the state of my program whenever the user clicks the "Save" button.

In my example, this is a user interface builder that allows the user to choose which "fields" should be displayed in the left and right columns on a two-column screen, along with the order of the fields in each column. There are other things, but you have an idea.

The user can open any configuration file that they saved and correctly populate the user interface builder.

I think this can be saved in an XML file, but I was wondering what suggestions people could write about how to write it, how to read it (use LINQ, maybe?) And other general approaches, including version control, etc. .d. I am sure this has happened before and I would like to hear about the best practices. Thank you

+1
source share
2 answers

The method I use for my program is to store the configuration values ​​in a class that uses the DataTable in the DataSet to store the values. When I want to save it, I use DataSet.WriteXML () for any file name that the user wants.

( DataTable , ), DataTables . DataSet io.

DataSet.ReadXML().

, , . , , , - , , - .

(, ), - , .

.

, :

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")

, .: -)

+4

? ... ... ?

, / ... ... ( ) . " " .

, . .

+6

All Articles