服务器参数配置文件config.json该怎么设置

服务器参数配置文件config.json该怎么设置,第1张

代码如下:请导入 SystemXML命名空间
string file = ServerMapPath(@"~\webconfig");
XmlDocument xmlDoc = new XmlDocument();
xmlDocLoad(file);
string s1 = "aaa";
string s2 = "bbb";
string h = "ccc";
string user = "ddd";
string pass = "eee";
XmlNodeList nodeList = null;
nodeList = xmlDocSelectSingleNode("configuration//connectionStrings")ChildNodes;
//遍历所有子节点
foreach (XmlNode xn in nodeList)
{
//将子节点类型转换为XmlElement类型
XmlElement xe = xn as XmlElement;
if (xeName == "add")
{
if (xeGetAttribute("name") == "acountConnectionString")
{
xeSetAttribute("connectionString", s1);
}
if (xeGetAttribute("name") == "mailaddress")
{
xeSetAttribute("connectionString", s2);
}
}
}
nodeList = xmlDocSelectSingleNode("configuration//systemnet//mailSettings//smtp")ChildNodes;
foreach (XmlNode xn in nodeList)
{
//将子节点类型转换为XmlElement类型
XmlElement xe = xn as XmlElement;
if (xeName == "network")
{
xeSetAttribute("host", h);
xeSetAttribute("userName", user);
xeSetAttribute("password", pass);
break;
}
}
xmlDocSave(file);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zz/13447612.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-08
下一篇 2023-08-08

发表评论

登录后才能评论

评论列表(0条)

保存