Visual Studio has Properties.Settings.Default and user settings management right from project properties.

In sharpdevelop there are no such amenities, but you can create the file someName.settings manually Add -> New item -> Misc -> Settings . Actually the question is how easy it is to turn to it in order not to reinvent the wheel. Suppose I have declared the variable string someVar = "some value" . How to read, rewrite and save?

    1 answer 1

    So the method of scientific poking brought the result. It turned out that the sharpdevelop file anyname.settings is just a convenient interface for adding stored parameters (the same as in the properties window of the visual studio project), and there can be a lot of them (such files).

    So, when creating the foo.settings and bar.settings in the testapp project and testapp bar and foo variables there, respectively, new branches appear in the app.config , which look like this:

      <userSettings> <testapp.foo> <setting name="bar" serializeAs="String"> <value>barValue</value> </setting> </testapp.foo> <testapp.bar> <setting name="foo" serializeAs="String"> <value>fooValue</value> </setting> </testapp.bar> </userSettings> 

    And now in the code you can do this:

     void MainFormLoad(object sender, EventArgs e) { //читаем значение string barVal = foo.Default.bar; // barValue //или так barVal = foo.Default.Properties["bar"].ToString(); // barValue //меняем значение foo.Default.bar = "New bar value"; //сохраняем параметры в реестр (будут доступны при следующих запусках приложения) foo.Default.Save(); //опять читаем barVal = foo.Default.bar; // New bar value //получаем значение по умолчанию barVal = foo.Default.Properties["bar"].DefaultValue.ToString(); // barValue } 

    All the same is true for the second branch:

     string fooVal = bar.Default.foo; // fooValue 

    By the way, after compilation everything from the app.config project, including the default values ​​of our parameters, goes into testapp.exe.config which should be in the same folder with the compiled testapp.exe .

    I hope someone will be useful.