首页 > 代码库 > AppSetting 用法

AppSetting 用法

<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
 
  <appSettings>
    <add key="bakName" value="WMSBAK"/>
    <add key="copyName" value="PRELL"/>
  </appSettings>
 
  <connectionStrings>
    <add name="Default" connectionString="Data Source=.;Initial Catalog=PRELL;Persist Security Info=True;User ID=sa;Password=123456;Pooling=true;Max Pool Size=100000;Min Pool Size=0;Connection Lifetime=3000;packet size=32767;Connection Reset=false" providerName="System.Data.SqlClient"/>
  </connectionStrings>
 
</configuration>

 

获取方法

namespace WMSBAK
{
    public class WMSBackUp
    {
        private string BakDBName
        {
            get { return System.Configuration.ConfigurationManager.AppSettings["bakName"]; }
        }
        private string CopyDBName
        {
            get { return System.Configuration.ConfigurationManager.AppSettings["copyDBName"]; }
        }
    }
}