//把读到的配置文件放到_datatable中、、
string file = Application.ExecutablePath;
_config = ConfigurationManager.OpenExeConfiguration(file);
_datatable = new DataTable();
DataRow datarow;
AppSettingsSection appSettings = (AppSettingsSection)_config.GetSection("appSettings");
string[] keys = appSettings.Settings.AllKeys;
_datatable.Columns.Add("配置项");
_datatable.Columns.Add("参数值");
for (int j = 0; j < keys.Length; j++)
{
datarow = _datatable.NewRow();
string key = keys[j];
string value = _config.AppSettings.Settings[key].Value;
datarow["配置项"] = key;
datarow["参数值"] = value;
_datatable.Rows.Add(datarow);
}//对修改的值进行保存。
int rowIndex = e.RowHandle;
GridColumn column = e.Column;
int columnIndex = grvConfig.Columns.IndexOf(column);
string value = grvConfig.GetFocusedRowCellValue("参数值").ToString();
string chiKey = grvConfig.GetFocusedRowCellValue("配置项").ToString();
string engKey = engAryline[rowIndex];
for (int i = 0; i < keys.Length;i++ )
{
if (engKey == keys[i])
{
_config.AppSettings.Settings[engKey].Value = value;
}
}
_datatable.Rows[rowIndex][columnIndex] = value;
解决方案 »
- 表格单元格不换行
- 关于ToolStripStatusLabel显示内容的问题,请教高手!!!
- 求助:关于闹钟时间框
- 计算器的小小问题
- 新手不耻下问,天天请教
- 未将对象引用设置到对象的实例的错误
- 有谁作过飞天诚信的epass1000c#接口
- 关于split函数,将int数拆分后存入char[]为何不对??
- Winxp怎么才能运行Win2003+VS2005+SQL2005开发的winform程序,需要装什么?
- 我想知道如何在Oracle上跨数据库查询和插入
- 百度云推送 c# sdk 有人做过吗?
- C#报错:common language runtime detected an invalid program
那么它默认的配置文件就是 exe.config
我修改了参数,.exe.config也修改了,但是项目中的app.config没改变啊,下次运行它会不会又把exe.config的值还原成app.config的值你?
app.config和exe.config什么联系呢?
谢谢 给讲一讲
在bin\Debug或者bin\Release下面去看
app.config是没有的,只有exe.config.
修改config文件后记得保存,
配置項是不会丢掉的
在bin\Debug或者bin\Release下面去看
app.config是没有的,只有exe.config.
修改config文件后记得保存,
配置項是不会丢掉的
在bin\Debug或者bin\Release下面去看
app.config是没有的,只有exe.config.
修改config文件后记得保存,
配置項是不会丢掉的
我的意思是为什么我项目中的app.config不跟着修改呢?
我的意思是为什么我项目中的app.config不跟着修改呢?
我的意思是为什么我项目中的app.config不跟着修改呢?
那app.config不修改,会不会把bin下的.exe.config给刷新掉?
主要重新编译一下 不就把bin下的.exe.config给刷新掉了吗?
选择始终复制也不变啊?是不是我代码有问题?
//获取当前运行程序的可执行文件的路径。
string file = Application.ExecutablePath;
//绑定打开配置文件
Configuration _config = ConfigurationManager.OpenExeConfiguration(file);
对_config 操作修改
//之后就是保存,刷新
_config.Save();
ConfigurationManager.RefreshSection("configuration");
帮忙看看?什么问题呢到底是?