Using system;
Using system. xml;
Using system. configuration;
/** // <Summary>
/// Read the configuration file
/// Config operation class
/// </Summary>
Public class confighelper
{
Public confighelper ()
{
//
// Todo: add the constructor logic here
//
}
Getconfigvalueofkey (string key) to get the value of the configuration file # region getconfigvalueofkey (string key) to get the value of the configuration file
// # Region abstract createconfigvalueofkey needs to be developed
// Public void createconfigvalueofkey (string key, string keyValue)
//{
//
//}
// # Endregion
Updateconfigvalueofkey # region updateconfigvalueofkey
Public void updateconfigvalueofkey (string key, string keyValue)
{
Xmldocument Doc = new xmldocument ();
// Obtain the full path of the configuration file
String strfilename = appdomain. currentdomain. basedirectory. tostring () + "app. config ";
Console. writeline (strfilename );
// Return;
Doc. Load (strfilename );
// Find all elements named "add"
// Bool isexist = false;
Xmlnodelist nodes = Doc. getelementsbytagname ("add ");
For (INT I = 0; I <nodes. Count; I ++)
{
// Obtain the key attribute of the current element
Xmlattribute ATT = nodes [I]. attributes ["key"];
// Determine whether the current element is a target element based on the first attribute of the element.
If (Att. value. tostring (). Equals (key ))
{
// Assign values to the second attribute of the target Element
ATT = nodes [I]. attributes ["value"];
Att. value = keyValue;
// Isexist = true;
Break;
}
}
// Save the modification above
Doc. Save (strfilename );
}
# Endregion
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.