473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to maintain user.config settings when upgrading?

I have a basic question about managing user.config settings:

In my C# app, I save the user's preferences to the config file. But
each time I release a new build of the app, something in .NET creates a
new folder (named for the build number) in Documents And Settings. The
result is the users lose all their settings and have to start over.

What is the standard way to allow users to maintain their settings when
they get a new version of a .NET app?

thanks
Dave

Aug 10 '06 #1
3 24471

<da*****@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
>I have a basic question about managing user.config settings:

In my C# app, I save the user's preferences to the config file. But
each time I release a new build of the app, something in .NET creates a
new folder (named for the build number) in Documents And Settings. The
result is the users lose all their settings and have to start over.

What is the standard way to allow users to maintain their settings when
they get a new version of a .NET app?
You could store them in a different file or use the registry.
Aug 10 '06 #2
<da*****@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
>I have a basic question about managing user.config settings:

In my C# app, I save the user's preferences to the config file. But
each time I release a new build of the app, something in .NET creates a
new folder (named for the build number) in Documents And Settings. The
result is the users lose all their settings and have to start over.

What is the standard way to allow users to maintain their settings when
they get a new version of a .NET app?
Here's the way I do it - ClickOnce does something similar automatically.
You need to make use of the SettingsBase.Upgrade method.

Add a Setting to your project called ApplicationVersion, then use code like
the following in the startup of your applicaiton:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
Version appVersion = a.GetName().Version;
string appVersionString = appVersion.ToString();

if (Properties.Settings.Default.ApplicationVersion != appVersion.ToString())
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.ApplicationVersion = appVersionString;
}

-cd
Aug 10 '06 #3

This suggestion worked perfectly. Thanks.
Dave
Carl Daniel [VC++ MVP] wrote:
Here's the way I do it - ClickOnce does something similar automatically.
You need to make use of the SettingsBase.Upgrade method.

Add a Setting to your project called ApplicationVersion, then use code like
the following in the startup of your applicaiton:
...
Aug 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bit Twiddler | last post by:
Hi, I have a windows form app which would benefit from the new application settings support in VS2005. Say that my form has a single textbox on it. When the form closes I would like to save...
0
by: Chad A. Beckner | last post by:
Hi everyone, I have a common class library (call it common_library) that I include/reference in my projects. In this class library, I would like to have it save certain settings to the...
0
by: Nenad Dobrilovic | last post by:
Hi all, I have a really strange situation, but I believe that there is someone else who has already experinced the same, and is willing to help me! I made an application using VS 2005 in C#,...
1
by: logicnet.dk | last post by:
Is it possible to decide where user.config is stored by Properties.Settings.Default.Save? The default location seems to be "C:\Documents and Settings\\Local settings\Application Data\\\" and there...
1
by: Matt F | last post by:
Two of the projects in my solution that both need to use a common user.config file. This is a data application - the executable that is created with the first project is the primary executable...
3
by: Jeremy Chaney | last post by:
It appears that my user.config file got corrupted causing my "InitializeComponent" routine to throw the exception "Root element is missing." when I start my app. I figure I can just go into...
3
by: Gary Brown | last post by:
Hi, My "Local Settings/Application Data" directory contains several copies "user.config" differentiated by random gibberish added to program file name. What is the purpose of more than one...
0
by: Someguy | last post by:
I have application settings working for my dll however I can't seem to get the same result with user settings? I assume I need to open 2 configuration managers as shown below. Any idea what I'm...
3
by: Piotrekk | last post by:
Hi I have a problem connected with user.config file. I am using default settings.settings . To settings.settings I am adding one user scope string and one application scope string. Thus...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.