验证中...
C# Winfrom Config配置文件参数读写
Raw Copy
//config 配置文件内容
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="CompanyCode" value="68" />
<add key="CompanyName" value="深圳市科技股份有限公司" />
</appSettings>
</configuration>
//C#代码
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//读取公司名称和代码
txtCompanyCode.Text = config.AppSettings.Settings["CompanyCode"].Value;
txtCompanyName.Text = config.AppSettings.Settings["CompanyName"].Value;
//写入
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["CompanyCode"].Value = txtCompanyCode.Text;
config.AppSettings.Settings["CompanyName"].Value = txtCompanyName.Text;

Comment list( 1 )

熊运生 2019-08-09 23:56

已get

You need to Sign in for post a comment

Help Search