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;
}
查看全文
相关阅读:
软件需求与建模 复习笔记
Autoware 笔记No.9,SSD车辆、行人(障碍物)识别(ssd vision detect)
Autoware 笔记No.8 ENet 障碍物识别(vision segment ENet detect)
Autoware 1.14 完整安装
Autoware 笔记No.7, CNN障碍物检测(CNN LiDAR Baidu Object Segmenter)
iOS 使用局部block处理接口依次调用需求
阿里一面凉经
Codeforces round #717 D.Cut(m询问求区间[L,R]能被至少分成多少个区间让每个小区间各数的乘积==各数的LCM)
2018-2020 国家集训队论文选读
GDOI 2021 游记
原文地址:https://www.cnblogs.com/lidune/p/546752.html
最新文章
第05组 Alpha冲刺(1/4)
C语言博客作业08
C语言I博客作业09
系统坏道检测
机械盘直接鸡鸡
Utool
提高电脑网速
本地策略组
项目原型设计
团队作业第二次—项目选题报告
热门文章
火鸡堂团队 团队展示
团队作业第六次—团队Github实战训练
团队作业第五次—项目系统设计与数据库设计
项目需求分析
团队作业第三次——项目原型设计(追光的人)
团队作业第二次—项目选题(追光的人)
追光的人 团队团队展示
团队作业第二次—项目选题报告
SkyReach 团队团队展示
数据库 学习笔记
Copyright © 2011-2022 走看看