How Do I Read Settings from the Config File?

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

I have a config file which contains settings for several projects. How
do I read the settings for one project from within another project's
code?

I'm using Visual Studio 2005 and NET 2.0.

-TC
 
TC said:
I have a config file which contains settings for several projects. How
do I read the settings for one project from within another project's
code?

I'm using Visual Studio 2005 and NET 2.0.

-TC

Her's some stuff to look at:

Private _config As Configuration
Private _appSet As AppSettingsSection

If _appSet Is Nothing Then

Dim map As New ExeConfigurationFileMap() With
{.ExeConfigFilename = Replace(Windows.Forms.Application.StartupPath &
"\myapp.exe.config", "\", "\")}

_config =
ConfigurationManager.OpenMappedExeConfiguration(map,
ConfigurationUserLevel.None)

_appSet = _config.AppSettings

End If
 
Her's some stuff to look at:

    Private _config As Configuration
    Private _appSet As AppSettingsSection

If _appSet Is Nothing Then

                Dim map As New ExeConfigurationFileMap() With
{.ExeConfigFilename = Replace(Windows.Forms.Application.StartupPath &
"\myapp.exe.config", "\", "\")}

                _config =
ConfigurationManager.OpenMappedExeConfiguration(map,
ConfigurationUserLevel.None)

                _appSet = _config.AppSettings

            End If

Harry,

Thank you for the reply. I don't yet understand how your code works,
but I'll study it and see if it works for me.

-TC
 
Back
Top