在web.config里加了几个appsetting的值,想通过程序来动态修改,如何做?
解决方案 »
- sqlhelper 与 DbHelper与 Enterprise Library 都是什么?之间有什么关系?有什么区别?适合什么场所
- FCKeditor简单问题 下班结帖!
- linq高手帮帮忙,关于linq多表左连接查询出错!在线等,急急急
- 就下面这句话写个代码看看啊
- ASP.NET2.0中Cache的生命周期是怎样的呢?
- 【求】有关OA的英文文档(顶者有分)
- Datagrid中的程序问题
- 求助,SqlDataSource获取session错误原因?
- 帮帮忙! 解决问题高分送出。
- 查看 .aspx 页面生成的控件树
- DataList或Reapter中的button可以添加脚本吗?
- 一个javascript的图片转换问题!高分求解。。。。。!!!!!(在线)
public void Modify(string key,string strValue) //两个参数:要修改的键值 和 要修改的新值;
{
string XPath="/configuration/appSettings/add[@key='?']";
XmlDocument domWebConfig=new XmlDocument();
domWebConfig.Load( (HttpContext.Current.Server.MapPath("web.config")) );
XmlNode addKey=domWebConfig.SelectSingleNode( (XPath.Replace("?",key)) );
if(addKey == null)
{
//throw new ArgumentException("没有找到<add key='"+key+"' value=.../>的配置节");
Response.Write("<script>alert (\"没有找到<add key='"+key+"' value=.../>的配置节\")</script>");
return;
}
addKey.Attributes["value"].InnerText=strValue;
domWebConfig.Save( (HttpContext.Current.Server.MapPath("web.config")) );
}
WEB.CONFIG本身也是一个XML文档.