VB.NET how to move app.config files to a custom location

I have an application that has a bunch of values ​​in its app.exe.config file. The application is used by a small number of users and the settings will be changed periodically. So I have to change the configuration file and Send it to all users.

I like to move the configuration file somewhere on the network and point the application to this file. I’ve tried to use it

p>

Imports System.Configuration.ConfigurationManager

OpenExeConfiguration("I:\app config\HelpDeskQuickCallLogger.exe.config")

But I can’t make it read values.

Any ideas?

If a specific configuration file (sSpecificConfigurationFile) is specified, this is how we handle this request:

Dim oConfig As System.Configuration.Configuration

If sSpecificConfigurationFile.EndsWith(".config", StringComparison.InvariantCultureIgnoreCase) Then
Dim oMap As New ExeConfigurationFileMap
oMap.ExeConfigFilename = sSpecificConfigurationFile
oConfig = ConfigurationManager.OpenMappedExeConfiguration(oMap, ConfigurationUserLevel.None)
Else
oConfig = ConfigurationManager.OpenExeConfiguration(sSpecificConfigurationFile)< br /> End If

I have an application that has a bunch of values ​​in its app.exe.config file. The application is used by a small number of users and the settings will be changed regularly .So I have to change the configuration file and send it to all users.

I like to move the configuration file somewhere on the network and point the application to this file. I’ve tried to use

Imports System.Configuration.ConfigurationManager

OpenExeConfiguration("I:\app config\HelpDeskQuickCallLogger.exe.config")

But I can’t make it read the values.

Any ideas?

If a specific configuration file (sSpecificConfigurationFile) is specified, this is how we handle this request:

Dim oConfig As System.Configuration.Configuration

If sSpecificConfigurationFile.EndsWith(".config", StringComparison.InvariantCultureIgnoreCase) Then
Dim oMap As New ExeConfigurationFileMap
oMap .ExeConfigFilename = sSpecificConfigurationFile
oConfig = ConfigurationManager.OpenMappedExeConfiguration(oMap, ConfigurationUserLevel.None)
Else
oConfig = ConfigurationManager.OpenExeConfiguration(sSpecificConfigurationFile)
End If

Leave a Comment

Your email address will not be published.