The following is the definition of app. config or web. config. A parameter is defined. The key is Isinit and the value is false.
<? Xml version = "1.0"?>
<Configuration>
<Deleetask>
<Add key = "IsInit" value = "false"/>
</AppSettings>
</Configuration>
The method definition for reading and writing the config file is as follows:
Write:
Copy codeThe Code is as follows: internal void settingApp_write (string key, string val)
{
System. Configuration. Configuration config = ConfigurationManager. OpenExeConfiguration (ConfigurationUserLevel. None );
Config. etettings. Settings ["IsInit"]. Value = val;
Config. Save (ConfigurationSaveMode. Modified );
ConfigurationManager. RefreshSection ("receivettings ");
}
Read:Copy codeThe Code is as follows: internal string settingApp_read (string key)
{
Var val = ConfigurationManager. deleetask[ key];
Return val;
}
Usage:
Write test:
SettingApp_write ("IsInit", "true ");
Fetch test:
Var setting = settingApp_read ("Isinit ");
This level of modification is the configuration file modification at the project level, that is, the operation of the config file under the Bin directory of your final program.