Dynamically load user.config

  • Thread starter Thread starter lee atkinson
  • Start date Start date
L

lee atkinson

Hi - is it possible to load a user.config file?

What I would like to do is to be able to load a user.config file and
then set the current properties to the properties within that file.
This would then allow the user to download their own user settings.

I could of course parse the XML and do it that way, but I thought there
may be a better and easier way.

Thanks
 
lee atkinson said:
Hi - is it possible to load a user.config file?

What I would like to do is to be able to load a user.config file and
then set the current properties to the properties within that file.
This would then allow the user to download their own user settings.

I could of course parse the XML and do it that way, but I thought there
may be a better and easier way.

Thanks

Not sure if this is what you want, but in your app.config or web.config you
can reference an user.config file like this:

<appSettings file="user.config">
<add key="ConnectionString" Value="..." />
</aapSetting>

In your user.config

<appSettings>
<add key="ConnectionString Value="something else" /?
</appSettings>

Cheers,

Aaron
http://aaronfeng.blogspot.com/
 
Hi Aaron

I should have made it clear it was .NET 2.0

What I did was to copy over the user.config, then call
Settings.Reload()

Lee
 
lee atkinson said:
Hi Aaron

I should have made it clear it was .NET 2.0

What I did was to copy over the user.config, then call
Settings.Reload()

Lee

For example, if you have a user.config and app.config both files have the
ConnectionString property when you do:

ConfigurationManager.AppSettings["ConnectionString"];

It will return the value that is stored in the user.config not app.config.
Assuming you set it up like I showed you before, and make sure you copy the
user.config when you finish compiling (set this in Visual Studio). Sometimes
you might need to "touch" the app.config for it to pickup the user.config.

This will allow people who have user.config setup use a different
configuration.

Cheers,

Aaron
http://aaronfeng.blogspot.com
 
Hi Aaron - as I said, I'm using .NET 2.0.

Although your solution is valid in version 2.0, it's more apt for
version 1.0.

I'm actually talking about the user.config files that are supported and
managed by .NET 2.0.

My solution worked fine anyhow.

Lee
 
Back
Top