The following methods are modified, and the add-in app. config does not show the modified stuff.
Method One: Through the use of System.Xml.XmlDocument to the image of the method in Bin\debug\~.vshost.exe.config configuration changes. (This method will not take effect until the next time the program is active until you clear the item and re-modify it to restore the configuration information you wrote)
Public Static voidSetValue (StringAppKey,StringAppvalue)
{
System.Xml.XmlDocument XDoc= NewSystem.Xml.XmlDocument ();
Xdoc.load (System.Windows.Forms.Application.ExecutablePath+ ". config");
System.Xml.XmlNode XNode;
System.Xml.XmlElement xElem1;
System.Xml.XmlElement xElem2;
XNode=Xdoc.selectsinglenode ("AppSettings");
XElem1=(System.Xml.XmlElement) Xnode.selectsinglenode ("add[@key = '" + AppKey + " '] );
if (xElem1 != null) Xelem1.setattribute ( "value else
{
If this does not add
XElem2=Xdoc.createelement ("Add");
Xelem2.setattribute ("Key", AppKey);
Xelem2.setattribute ("value", Appvalue);
Xnode.appendchild (XELEM2);
}
Xdoc.save (System.Windows.Forms.Application.ExecutablePath + ". config");
}
< Span style= "color: #000000;" >< Span style= "color: #800000;" >< Span style= "color: #800000;" > method Two: Use the configuration to modify the image. (This method takes effect immediately, but does not take effect the next time you activate)
< Span style= "color: #800000;" >< Span style= "color: #000000;" > CONF. appsettings.settings["FilePath"]. Value = FBD. SelectedPath (new value for setup);
conf. Save (configurationsavemode.modified);
configurationmanager.refreshsection ("appSettings");
WinForm How to change the content in the app. config file