When you need save and read some parameters which related about your settings or something else;
1. If your project does not have a "App.config" file; to make new one, right click your project and "Add->New Item->App Configuration File".
2. Open "App.Config" file and view your file like that;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System">
<section name="DevExpress.LookAndFeel.Design.AppSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<appSettings>
<add key="deviceModel" value="0" />
</appSettings>
</configuration>
This is a code snippet for read value and change and save procedure;
var appSettings=ConfigurationManager.AppSettings;
if (appSettings["deviceModel"].Length!=0)
{
textBox1.Text = appSettings["deviceModel"].ToString();
}
int tempVal;
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
if (settings["deviceModel"] == null)
{
settings.Add("deviceModel", "1");
}
else
{
tempVal = int.Parse(settings["deviceModel"].Value);
tempVal++;
settings["deviceModel"].Value = tempVal.ToString();
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);