读写 配置文件 程序里面修改了配置文件的内容下几行代码马上进行读取里面更新的内容这时候取到的内容往往还没有更新有什么方法可以等待更新了在获取 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 加一句Thread.Sleep( 2000 ); 试试在再次读取前调用Application.DoEvents() private void button1_Click(object sender, EventArgs e) { ExeConfigurationFileMap file = new ExeConfigurationFileMap(); file.ExeConfigFilename = @"..\..\App.config "; Configuration myConfig = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None); AppSettingsSection appsection = (AppSettingsSection)myConfig.GetSection("appSettings"); string m_str1 = appsection.Settings["mappath"].Value; file.ExeConfigFilename = @"..\..\App.config "; appsection.Settings["mappath"].Value = "456"; myConfig.Save(System.Configuration.ConfigurationSaveMode.Minimal, true); string m_str2 = appsection.Settings["mappath"].Value; }使用这种方法,我可以直接得到改变的数据。 =================反编译后代码里面有[Dynamic(new bool[]{false,true})]编译不过============= 用正则找出网页中某id是否含有指定字符串? 继承WebBrowser后,无法弹出“发送信息框” 如何根据字节长度截取字符串? CodeSmith 如何连接 Access 数据库请各位高手帮忙 C#中string 类型的比较?? C#正则表达问题[高手请进!!] 怎样提出dll中的ico? 如保获取DATAGRID当前格的座标? 作一个网站在线人数的功能怎么做 只差100万次,程序的运行时间就有很大差别 关于SQL语句在C#引用的问题
Thread.Sleep( 2000 );
private void button1_Click(object sender, EventArgs e)
{
ExeConfigurationFileMap file = new ExeConfigurationFileMap();
file.ExeConfigFilename = @"..\..\App.config ";
Configuration myConfig = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);
AppSettingsSection appsection = (AppSettingsSection)myConfig.GetSection("appSettings");
string m_str1 = appsection.Settings["mappath"].Value;
file.ExeConfigFilename = @"..\..\App.config ";
appsection.Settings["mappath"].Value = "456";
myConfig.Save(System.Configuration.ConfigurationSaveMode.Minimal, true); string m_str2 = appsection.Settings["mappath"].Value;
}使用这种方法,我可以直接得到改变的数据。