1: //<summary>
2: ///Modify the Value property in the Add in the Config section of the Web. config or app. config file appsettings
3: //</summary>
4: //<remarks>
5: ////Note that this function will cause the entire Web application to be restarted, causing all current sessions to be lost
6: //</remarks>
7: ///<param name= "key" > key to be modified key</param>
8: ///<param name= "strvalue" > Modified value</param>
9: ///<exception cref= "" > Cannot find the relevant key </exception>
:/ //<exception cref= "" > Insufficient permissions to save to the Web. config file </exception>
One : publicstaticvoid modifyappsettings (string string strvalue)
: {
: string"/configuration/appsettings/add[@key = '? ']";
: new XmlDocument ();
:
: "/application1.exe.config");
: XmlNode addkey = Domconfig.selectsinglenode ((Xpath.replace ("?", key));
: ifnull)
: {
: thrownew ArgumentException ("no <add key= found " "' value=.../> configuration section");
: }
: addkey.attributes["value"]. InnerText = strvalue;
: "/application1.exe.config");
:
: }
£ º
+ / /<summary>
/ / //////For the Value property in the Add in the Config section of the web. AppSettings or app. config file
:/ /</summary>
:/ //<param name= "key" > key to be modified key</param>
+ / -<param name= "strvalue" > Modified value</param>
:/ //<exception cref= "" > Cannot find the relevant key </exception>
+ / /<exception cref= "" > Insufficient permissions to save to the Web. config file </exception>
: publicstaticstring getappsettings (string Key
: {
A : string"/configuration/appsettings/add[@key = '? ']";
Panax notoginseng : new XmlDocument ();
:
: "/application1.exe.config");
Max : XmlNode addkey = Domconfig.selectsinglenode ((Xpath.replace ("?", key));
: ifnull)
: {
: thrownew ArgumentException ("no <add key= found " "' value=.../> configuration section");
: }
: return addkey.attributes["value"]. InnerText;
: }