winform app.cpnfig 文件的引用

1.app.config配置文件修改

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="connectionString" connectionString="data source=127.0.0.1;persist security info=True;user id=test;password=test123" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="verson" value="1.0.0" />
    <add key="DownLoad" value="2" />
  </appSettings>
</configuration>

2.连接字符串的引用

  •   添加引用

winform app.cpnfig 文件的引用

using System.Configuration;
  •   连接字符串调用
 string conStr = ConfigurationManager.ConnectionStrings["connectionString"].ToString();
            MessageBox.Show(conStr);

3.appSettings 配置的调用

            Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            string strval = cfa.AppSettings.Settings["DownLoad"].Value;
            MessageBox.Show(strval);

 

  

winform app.cpnfig 文件的引用

上一篇:java/android 做题中整理的碎片小贴士(15)


下一篇:iOS学习四之UITextField