public void ChangeConfigValue()
{
string filename = System.AppDomain.CurrentDomain.BaseDirectory + @"web.config";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(filename);
XmlNodeList nodeList = xmldoc.DocumentElement.ChildNodes;
foreach (XmlElement element in nodeList)
{
if (element.Name.ToLower() == "appsettings")
{
XmlNodeList node = element.ChildNodes;
if (node.Count > 0)
{
foreach (XmlElement el in node)
{
if (el.Attributes["key"].InnerText == "ConnectionString")
{
el.Attributes["value"].InnerText = "321";//write the value
string s= el.Attributes["value"].InnerText;//read the value
break;
}
}
}
break;
}
}
xmldoc.Save(filename);
}
Blog Archive
-
▼
2008
(15)
-
▼
November
(12)
- A DetailsView Control for ASP.NET (Putting It All ...
- Move Over DataGrid, There's a New Grid in Town!
- Letter/Alphanumeric Based Paging in ASP.NET
- ASP.NET Site-Map Security Trimming
- How To populating DropDownList control from XML data
- How to read XML file using javascript
- How To Redirect into a new window using Response.R...
- Building a Simple CSV Parser in C#
- read, write and save values in app.config file
- How To Create TextBox Dynamically using Javascript...
- How To Create TextBox Control Dynamically at Runtime
- AJAX Database Example in Asp.net
-
▼
November
(12)
Friday, November 14, 2008
read, write and save values in app.config file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment