zoukankan
html css js c++ java
读写xml文件结点值
public
static
void
UpdateConfig(
string
item,
string
itemvalue)
{
try
{
//
将连接字符串写入Web.config
System.IO.FileInfo fileInfo
=
new
FileInfo(AppDomain.CurrentDomain.BaseDirectory
+
"
DataBase.xml
"
);
if
(
!
fileInfo.Exists)
MessageBox.Show(
"
can't find the app.config
"
);
XmlDocument doc
=
new
XmlDocument();
doc.Load(fileInfo.FullName);
//
doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
bool
foundIt
=
false
;
string
connString
=
itemvalue;
string
enCS
=
connString;
//
SecurityHelper.EncryptDBConnectionString(connString);
XmlNode no
=
doc.SelectSingleNode(
"
//appSettings/add[@key='
"
+
item
+
"
']
"
);
if
(no
!=
null
)
{
no.Attributes.GetNamedItem(
"
value
"
).Value
=
enCS;
foundIt
=
true
;
}
if
(
!
foundIt)
MessageBox.Show(
"
can't find the connString setting
"
);
doc.Save(fileInfo.FullName);
}
catch
(Exception ex)
{
StreamWriter w
=
new
StreamWriter(AppDomain.CurrentDomain.BaseDirectory
+
"
log.txt
"
,
true
);
w.WriteLine(
"
===in updata connstring=tjtj=====
"
);
w.WriteLine(ex.ToString());
w.WriteLine(ex.StackTrace);
w.Close();
}
}
public
static
string
LoadConfig(
string
item)
{
string
reval
=
""
;
try
{
//
将连接字符串写入Web.config
System.IO.FileInfo fileInfo
=
new
FileInfo(AppDomain.CurrentDomain.BaseDirectory
+
"
DataBase.xml
"
);
if
(
!
fileInfo.Exists)
MessageBox.Show(
"
can't find the app.config
"
);
XmlDocument doc
=
new
XmlDocument();
doc.Load(fileInfo.FullName);
//
doc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
bool
foundIt
=
false
;
XmlNode no
=
doc.SelectSingleNode(
"
//appSettings/add[@key='
"
+
item
+
"
']
"
);
if
(no
!=
null
)
{
reval
=
no.Attributes.GetNamedItem(
"
value
"
).Value;
foundIt
=
true
;
}
if
(
!
foundIt)
MessageBox.Show(
"
can't find the connString setting
"
);
}
catch
(Exception ex)
{
StreamWriter w
=
new
StreamWriter(AppDomain.CurrentDomain.BaseDirectory
+
"
log.txt
"
,
true
);
w.WriteLine(
"
===in updata connstring=tjtj=====
"
);
w.WriteLine(ex.ToString());
w.WriteLine(ex.StackTrace);
w.Close();
}
return
reval;
}
查看全文
相关阅读:
VS2017专业版和企业版激活密钥
RabbitMQ卸载重新安装
RabbitMQ-基本命令操作
天猫
铜氨纤维
四肢很发达,头脑不简单
运动可以健身健脑
1 职业天花板来自认识的局限性
天猫-服饰行业标准
服装设计都是需要什么
原文地址:https://www.cnblogs.com/lidune/p/546752.html
最新文章
ASP.NET Core WebApi使用Swagger
对应数据增长很大的表 需要做分表或者分区处理 然后定期清理历史分区
vue2.0中ckeckbox(复选框)的使用心得,及对click事件和change的理解
小程序的坑你遇到过哪些?
SqlServer 2016服务器配置远程访问
盘点我在安装SqlServer 2016时遇到的问题
python-时间差值计算
python学习笔记-MySQL数据库连接相关
es6中的promise解读
es6中的类及es5类的实现
热门文章
es6展开运算符
实现一个深拷贝方法
es6箭头函数
IIS 8提示System.ServiceModel.Activation.HttpModule 错误
引用WCF服务后,数组默认替换了List泛型的解决办法
查看ORACLE中正在运行的存储过程 kill
Win10系统Nginx无法启动的问题解决方案
asp.net 导出excel文件名称乱码
asp.net webform使用log4net
c# webapi POST 参数解决方法
Copyright © 2011-2022 走看看