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:

    <add key="LocalDB" value="Data Source=;Initial Catalog=IMMCFG;uid=jimusr2;pwd=jimusr2"/>
    <add key="LocalDBP" value="Data Source=;Initial Catalog=IMMDBP;uid=jimusr2;pwd=jimusr2"/>
    <add key="JIMDBP" value="Data Source=;Initial Catalog=JIMDBP;uid=jimusr2;pwd=jimusr2"/>
    <add key="IMMDBP" value="Data Source=;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="" />

then, your application config file should look like this:

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


No comments:

Post a Comment