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;
}
查看全文
相关阅读:
[AHOI2006]文本编辑器 Splay tree区间操作
HDU-3487 Play with Chain Splay tee区间反转,移动
HDU-4619 Warm up 2 二分匹配
HDU-4618 Palindrome Sub-Array 暴力枚举
HDU-4616 Game 树形DP
HDU-4614 Vases and Flowers 线段树区间更新
HDU-4612 Warm up 边双连通分量+缩点+最长链
HDU-4611 Balls Rearrangement 循环节,模拟
HDU-4605 Magic Ball Game 树状数组+离散+dfs
HDU-3436 Queue-jumpers 树状数组 | Splay tree删除,移动
原文地址:https://www.cnblogs.com/lidune/p/546752.html
最新文章
Java 持久化操作之 --XML
Java 持久化操作之 --io流与序列化
Java 多线程
Java Eclipse和MyEclipse快捷键
css 初级进阶
JS中常见原生DOM操作API
apiCloud中的API对象
Android屏幕适配全攻略(最权威的官方适配指导)
android 学习运用海马模拟器教程与android环境的搭建
Redis Windows 安装
热门文章
面向对象---嵌套/特殊方法
面向对象--类成员&成员修饰符
封装/多态/继承
PEP8
爬虫-ip代理
Python中的迭代器&生成器
爬虫的cookie
细说python模块
python装饰器
[NOI2005]维修数列 Splay tree 区间反转,修改,求和,求最值
Copyright © 2011-2022 走看看