如果我要设置:
<network host="hostname" port="25" userName="[email protected]" password="xxxx"/>
那我要写在哪个节点下面?
然后要乍么取?
<network host="hostname" port="25" userName="[email protected]" password="xxxx"/>
那我要写在哪个节点下面?
然后要乍么取?
解决方案 »
- 指定的转换无效。
- c#问题
- [ConfigurationProperty("id")]类似于这样的表达式是什么意思啊?
- 谁能给我解释下我经理的意思!(C# WINFORM 打印机)
- C#如何才能过滤特定的字符?
- 请问函数前的 [Serializable] 和[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] 这类语法表示什么有什么
- 删除最后一条记录的问题
- C# 如果转换成有效的16进制数
- 知道文件路径,如何将该文件上传到服务器 (急!!!)
- 如何注册动态添加的控件的事件?
- 怎么实现 windows 我的电脑窗口的左边那栏点击后展现收起的功能
- c#中,简单的工厂类大致是怎么写
你可以:
<add key="host" value="hostname"/>
<add key="port" value="25"/>
。
然后
string host= System.Configuration.ConfigurationSettings.AppSettings.Get("host");
string port= System.Configuration.ConfigurationSettings.AppSettings.Get("port");
要在 <appSettings >
<add key="host" value="hostname"/>
<add key="port" value="25"/>
</appSettings>
用System.Configuration.ConfigurationSetting.AppSettings.Get("字段");
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings></appSettings>
<configSections>
<section name ="network" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<network>
<add key="host" value="hostname" />
<add key="post" value="25" />
<add key="username" value="aaaa" />
<add key="password" value="aaaaaa" />
</network>
</configuration>
<configuration>
<appSettings></appSettings>
<configSections>
<section name="network" type="System.Configuration.SingleTagSectionHandler"/>
</configSections>
<network host="hostname" post="25" username="test" password="dddddd" />
</configuration>
一种替换getielementByid 的方法: XmlElement xnl = (XmlElement)xmldom.SelectSingleNode("//*[@ID='port']")
*表示所有节点! @ID='port'表示属性id=port的第一个节点