会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
一路前行
路漫漫其修远兮,吾将上下而求索.
博客园
首页
新随笔
联系
订阅
管理
App.Config 操作类
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Xml;
namespace
DataUpper
{
abstract
class
AppConfig
{
public
static
string
ReadConfig(
string
strXmlKey)
{
return
System.Configuration.ConfigurationManager.AppSettings[strXmlKey].ToString();
}
public
static
void
SaveConfig(
string
strXmlKey,
string
strXmlValue)
{
XmlDocument doc
=
new
XmlDocument();
string
strFileName
=
AppDomain.CurrentDomain.BaseDirectory.ToString()
+
"
DataUpper.exe.config
"
;
doc.Load(strFileName);
XmlNodeList nodes
=
doc.GetElementsByTagName(
"
add
"
);
for
(
int
i
=
0
; i
<
nodes.Count; i
++
)
{
XmlAttribute xmlAtt
=
nodes[i].Attributes[
"
key
"
];
if
(xmlAtt.Value
==
strXmlKey)
{
xmlAtt
=
nodes[i].Attributes[
"
value
"
];
xmlAtt.Value
=
strXmlValue;
break
;
}
}
doc.Save(strFileName);
}
}
}
posted on
2008-12-01 16:55
一路前行
阅读(
529
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部