Friday 28 October 2011

Read External Config File in .NET

First, u must create one file with the extension .config
I named it as Global.config. All the appSettings reside in that file like below:


  <appSettings>
   
    <add key="LocalDB" value="Data Source=10.23.122.26;Initial Catalog=IMMCFG;uid=jimusr2;pwd=jimusr2"/>
    <add key="LocalDBP" value="Data Source=10.23.122.25;Initial Catalog=IMMDBP;uid=jimusr2;pwd=jimusr2"/>
    <add key="JIMDBP" value="Data Source=10.23.122.54;Initial Catalog=JIMDBP;uid=jimusr2;pwd=jimusr2"/>
    <add key="IMMDBP" value="Data Source=10.23.122.89;Initial Catalog=IMMDBP;uid=jimusr2;pwd=jimusr2"/>
    <add key="SERVER" value="XPS1640-PC" />
    <add key="DB" value="IMMCFG" />
    <add key="DB1" value="JIMDBP" />
    <add key="DB" value="IMMCFG" />
    <add key="DB1" value="JIMDBP" />
    <add key="UID" value="sa" />
    <add key="PWD" value="password" />
    <add key="AppVersion" value="1.2"/>
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>

then, your application config file should look like this:


 <appSettings file = "../CONFIG/Global.config">

  </appSettings>


No comments:

Post a Comment