WinForm读取config文件问题 为什么我的程序读取不了系统生成的config文件,我调试进去根本读不到值,全是null,是怎么回事啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是的,在 Debug 下面,注意不是web的哟 引用configurationmanager调用AppSettings或ConnectionStrings属性 是这样的,这个程序是以前就写好的,以前都能用,而且现在其他人,客户那里都能用,前几天我换笔记本了,就不能用了,而且我也重新编译了,好像就是读不到config文件 app.config<?xml version="1.0" encoding="utf-8" ?><configuration> <appSettings> <add key="test" value="testvalue"/> </appSettings></configuration>using System.Configuration; public void Test() { MessageBox.Show(System.Configuration.ConfigurationManager.AppSettings["test"]); } XmlDocument xDoc = new XmlDocument(); xDoc.Load(Application.ExecutablePath + ".config");XmlNode xNode = xDoc.SelectSingleNode(节点);string str= xNode.InnerText;这样试试 ConfigManager m_config=ConfigurationManager.OpenExeConfiguration("路径"); (m_Config.AppSettings.Settings["Server"] as KeyValueConfigurationElement).Value 读一个Server配置节点的值上面用你的配置文件的路径肯定能打开 ConfigManager 找不到类型或命名空间啊 你程序的References里面要添加System.configuration的引用 在解决方案的引用里添件System.Configuration.dll再Using System.Configuration; 引用添加System.Configuration.dll WPF程序启动很慢,请求解决方法 新人请教 c#中html的 帮忙看看错在哪里...希望能详细解答一下... 请问:如何通过数据库中的datetime字段判断是上午还是下午 关于在textBox中paint Visual Assist X是否支持 2005C# C# Form中绘制的图形分块缩放和平移 HttpWebRequest请求的URI中有中文,怎么办? 请帮忙翻译一下关 DCOM 的英文. C#的面向对象啊~ 帮忙看看我的代码,一头雾水啊 System.Diagnostics.Process.Start如何让打开的窗口没有菜单和状态栏? Winform有没画网络图的控件
调用AppSettings或ConnectionStrings属性
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="test" value="testvalue"/>
</appSettings>
</configuration>
using System.Configuration;
public void Test()
{
MessageBox.Show(System.Configuration.ConfigurationManager.AppSettings["test"]);
}
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.ExecutablePath + ".config");
XmlNode xNode = xDoc.SelectSingleNode(节点);
string str= xNode.InnerText;这样试试
ConfigManager m_config=ConfigurationManager.OpenExeConfiguration("路径");
(m_Config.AppSettings.Settings["Server"] as KeyValueConfigurationElement).Value 读一个Server配置节点的值上面用你的配置文件的路径肯定能打开
再Using System.Configuration;