c# appconfig的动态读写问题
来源:百度知道 编辑:UC知道 时间:2024/06/16 11:35:07
可是修改后 我再加载这个窗体(默认该窗体会再次读取该键值并写在一个控件上) 就无法正确读取修改后的该键值。读到的是
代码如下:
namespace checkApp
{
public partial class setupForm : Form
{
string strFileName = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\checkApp\checkApp\App.config";
XmlDocument doc = new XmlDocument();
public setupForm()
{
InitializeComponent();
}
private void setupForm_Load(object sender, EventArgs e)
{
ConfigurationManager.OpenExeConfiguration(strFileName);
System.Console.WriteLine("!!!!{0}", ConfigurationManager.AppSettings["begin"]);
DateTime be =new DateTime();
be = DateTime.Parse(DateTime.Now.ToShortDateString() + Configurat
这个问题我正好也遇到了,就是当我修改了配置文件后
程序不能马上应用更新
昨天弄了一天才解决
解决方法如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Xml;
namespace UISnibFrom
{
public partial class LoginFrm : Form
{
DrugStore.BLL.EmployeeInfo info = new DrugStore.BLL.EmployeeInfo();
public LoginFrm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (rdoaccess.Checked)
{
UpdateConfig("DBType", "Access");
if (OpenFileName == "")
{
MessageBox.Show("请选择数据库所在