CodePudding user response:
private void button1_Click (object sender, EventArgs e)
{
The Configuration config=ConfigurationManager. OpenExeConfiguration (ConfigurationUserLevel. None).
TestConfig tc=new TestConfig ();
Tc TestStr="333";
The config. Sections. The Add (" TestConfig ", tc);
The config. Save (ConfigurationSaveMode. Full);
}
Public sealed class TestConfig: ConfigurationSection
{
Public static TestConfig GetConfig ()
{
TestConfig TestConfig section=GetConfig (" ");
The return section.
}
Public static TestConfig GetConfig (string sectionName)
{
TestConfig section=(TestConfig) ConfigurationManager. GetSection (sectionName);
If (section==null)
Throw new ConfigurationErrorsException (sectionName "Section" + + "is not found.");
The return section.
}
[ConfigurationProperty (" TestStr IsRequired=false)]
Public string TestStr
{
The get
{
Return (string) base [" TestStr "];
}
Set
{
The base [" TestStr "]=value;
}
}
}
CodePudding user response:
You this is already doneCodePudding user response:
AppConfig is an XML,