How Do I Read Settings from the Config File?

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
 
H

Harry Strybos

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
 
T

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top