The following is the definition of app. Config or Web. config, defines a parameter, the key is Isinit, and the value is False
<?xml version= "1.0"?>
<configuration>
<appSettings>
<add key = "Isinit" value= "false"/>
</appSettings>
</configuration>
Here is the method definition for reading and writing the config file:
Write:
internal void Settingapp_write (string key, String val) { System.Configuration.Configuration config = Configurationmanager.openexeconfiguration (configurationuserlevel.none); Config. appsettings.settings["Isinit"]. Value = val; Config. Save (configurationsavemode.modified); Configurationmanager.refreshsection ("appSettings"); }
Read:
Internal string Settingapp_read (string key) { var val = configurationmanager.appsettings[key]; return Val; }
How to use:
Write test:
Settingapp_write ("Isinit", "true");
Remove test:
var setting = Settingapp_read ("Isinit");
This level of modification is the project-level config file modification, which is the operation of the config file in your final program Bin directory.