<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="logs.type" value="info, debug, error" />
<add key="YHMC" value="190E9A4F7BE78BE7" />
<add key="YHMM" value="190E9A4F7BE78BE7" />
<add key="ServiceIP" value="127.0.0.1" />
<add key="ServicePort" value="37777" />
<add key="Path" value="D:\Media\" />
<add key="ChanelCount" value="9" />
</appSettings>
</configuration>
using System.Configuration;
public string _ServiceIP = ConfigurationManager.AppSettings["ServiceIP"].ToString();
<configuration>
<appSettings>
<add key="logs.type" value="info, debug, error" />
<add key="YHMC" value="190E9A4F7BE78BE7" />
<add key="YHMM" value="190E9A4F7BE78BE7" />
<add key="ServiceIP" value="127.0.0.1" />
<add key="ServicePort" value="37777" />
<add key="Path" value="D:\Media\" />
<add key="ChanelCount" value="9" />
</appSettings>
</configuration>
using System.Configuration;
public string _ServiceIP = ConfigurationManager.AppSettings["ServiceIP"].ToString();
解决方案 »
- 程序假死问题
- 看下面链接- -
- 各位大虾,弟子出学c#,想下一个visual C# express,要中文版的,并且不要visual studio太大了,装不下。能否告诉我地址?我下了好多还是
- protected override void OnPaint(PaintEventArgs e)在何时运行?
- 求一sql查询语句
- 怎样访问网络上的文件?
- 100分跪求答案!
- c#设置提问。
- 火狐 谷歌 onblur事件找不到 e.clientX
- 如何进行文档版本的控制???
- 求能改变datagridview 单元格某个字体的颜色?
- 跪求 winform如何自动搜索,加载,引用office的dll文件?
比如:
/// <summary>
/// 设置app.config中的某个key的value.
/// </summary>
/// <param name="AppKey">key</param>
/// <param name="AppValue">value</param>
public static void SetValue(string AppKey, string AppValue)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load("AlertForm.exe.config");//此处配置文件在程序目录下
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
{
xElem1.SetAttribute("value", AppValue);
}
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save("AlertForm.exe.config");
}
<add key="AdministratorLoginNames" value="admin,lisa"/>
</appSettings>
string administratorLoginNames = System.Configuration.ConfigurationManager.AppSettings["AdministratorLoginNames"];
这个的话,你应该是读错树节名字了吧!!是"add key"但,我觉得...怎么你好像读得不是很正确呀!!using System.Configuration;
public string _ServiceIP = ConfigurationManager.AppSettings["ServiceIP"].ToString();直接就可以读出来了呀,何必还需要做树节呢,但确实我不知道你要作何用,或许你有你的用途,但要是论数据读取值,上边的两行代码,是绝对可以读出来的...
http://www.cnblogs.com/fish-li/archive/2011/12/18/2292037.html
记得给分!我严重缺分中!