Execonfigurationfilemap This class provides the ability to modify and obtain the specified config;
Create a new instance of Execonfigurationfilemap ECF;
and set the Execonfigfilename property to the config file path to operate;
Using the Configurationmanager.openmappedexeconfiguration method to get the object Configuration Config
Invokes the config provided by the Configuration object instance. Appsettings.settings[key]. Value can be modified or obtained by appsetting;
If the modification requires a call to the Save method,config. Save ();
<summary>///Get the AppSetting node value in the custom Index.config file//</summary>///<param name= "key" > node name </ param>///<returns></returns>public static string Getindexconfigvalue (String key) {string Indexconfigpath = @ "D:\indexConfig"; Execonfigurationfilemap ECF = new Execonfigurationfilemap (); Ecf. Execonfigfilename = Indexconfigpath; Configuration config = configurationmanager.openmappedexeconfiguration (ECF, Configurationuserlevel.none); return CONFIG. Appsettings.settings[key]. Value;} <summary>///Setting the AppSetting node value in the custom Index.config file//</summary>///<param name= "key" > node name </ param>///<returns></returns>public static bool Setindexconfigvalue (string key, String value) {string in Dexconfigpath = @ "D:\indexConfig"; Execonfigurationfilemap ECF = new Execonfigurationfilemap (); Ecf. Execonfigfilename = Indexconfigpath; Configuration config = configurationmanager.openmappedexeconfiguration (ECF, ConfiGurationuserlevel.none); Config. Appsettings.settings[key]. Value = value; Config. Save (); return true;}
C # Gets or sets the value of the specified config file