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;
}
查看全文
相关阅读:
《勇敢的心》
笔记本要来啦
DataSet学习笔记
俺终于可以回家了
没有事做,好无聊
TSQL语句实现清空数据库数据的代码,保留原有表形式和各种约束
查询重复数据的SQL语句
DataTable详解
索引使用大全
char和byte的转换
原文地址:https://www.cnblogs.com/lidune/p/546752.html
最新文章
CodeIgniter 的图像处理类
PHP的rawurlencode和urlencode 函数
在Windows 7下安装Oracle 11g的解决方法
css表格边框样式
让MySQL支持InnoDB
jQuery+php实现ajax文件即时上传
FormData
Oracle中dual表的用途介绍
完全卸载oracle11g步骤
正则表达式模式修正符
热门文章
在Netbeans中使用Struts2.0+Spring2.5+Hibernate框架(一)
Lotus Domino 与关系数据库的互操作知识集锦
FireFox与IE开发上的一些区别
为什么用Lotus Script给读者域或作者域赋值却不起作用
lotus notes 开发常用方法
Lotus Notes中文档查询的研究与实践
重新配置Lotus Domino 和 Lotus Notes
LOTUS NOTES公式归类
以Ajax方式显示Lotus Notes视图的javasript类库NotesView2
Lotus script 技巧
Copyright © 2011-2022 走看看