winform如何修改配置文件app.config 我想把lable的信息,如内容,字体大小,颜色,lable的位置坐标,lable的大小通过button1事件后写入app.config里,请问这个怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Configuaration.ConfiguarationManager.Set(); sting m_Path = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;//获取配置文件的路径XmlDocument m_Doc = new XmlDocument;m_Doc.Load(m_Path);下面就像操作XML文件一样操作就可以了 修改app.config中的数据App.config中格式如下:<?xml version="1.0" encoding="utf-8" ?><configuration> <configSections> <section name="UserInfo" type="System.Configuration.AppSettingsSection"/> <section name="directoryInfo" type="System.Configuration.AppSettingsSection"/> </configSections> <UserInfo> <add key="DVRUSR" value="" /> <add key="DVRPWD" value="" /> </UserInfo> <directoryInfo> <add key="defaultPath" value="22" /> <add key="savePath" value="11" /> </directoryInfo></configuration>SetSettingValue(m_configFile, "directoryInfo", "savePath", _folderPath);///////////////////////////////////////////////////////////////////////////////public static void SetSettingValueHandle(string argFileName, string argSection, string argKey, string argValue) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(argFileName); ConfigurationSection configSection = config.Sections[argSection]; if (configSection != null) { AppSettingsSection appSettingsSection = configSection as AppSettingsSection; if (appSettingsSection != null && appSettingsSection.Settings.Count > 0) { appSettingsSection.Settings[argKey].Value = argValue; } } config.Save(); } catch (Exception ex) { throw new ArgumentNullException(String.Format("{0}的设定文件" +"<configuration><{1}><{2}>的构成不存在", argFileName, argSection, argKey), ex); } } 吧他 当个XML文件操作就可以了 ~ 一个正则表达式替换问题 请教... 急... WEB图片放大缩小不失真 winform中截取某控件图像 如何实现WINFORM下对搜索引擎操作 地址栏字符串的获取问题 多路广播委托的标准定义 调用form1的异常 怎样用C#代码实现给文件夹添加用户啊? 关于游戏的一个问题 如何在控件设置小数位数? 从提取的数据集中再提取数据 int FaxTask.Task(string ino,string in1,string in2,string in3,string in4)是什么意思?
XmlDocument m_Doc = new XmlDocument;
m_Doc.Load(m_Path);
下面就像操作XML文件一样操作就可以了
App.config中格式如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="UserInfo" type="System.Configuration.AppSettingsSection"/>
<section name="directoryInfo" type="System.Configuration.AppSettingsSection"/>
</configSections>
<UserInfo>
<add key="DVRUSR" value="" />
<add key="DVRPWD" value="" />
</UserInfo>
<directoryInfo>
<add key="defaultPath" value="22" />
<add key="savePath" value="11" />
</directoryInfo>
</configuration>SetSettingValue(m_configFile, "directoryInfo", "savePath", _folderPath);
///////////////////////////////////////////////////////////////////////////////
public static void SetSettingValueHandle(string argFileName, string argSection, string argKey, string argValue)
{
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(argFileName);
ConfigurationSection configSection = config.Sections[argSection];
if (configSection != null)
{
AppSettingsSection appSettingsSection = configSection as AppSettingsSection;
if (appSettingsSection != null && appSettingsSection.Settings.Count > 0)
{
appSettingsSection.Settings[argKey].Value = argValue;
}
} config.Save();
}
catch (Exception ex)
{
throw new ArgumentNullException(String.Format("{0}的设定文件" +"<configuration><{1}><{2}>的构成不存在", argFileName, argSection, argKey), ex);
}
}