473,503 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 24513

<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
2429
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
1328
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
1209
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
6451
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
5122
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
10474
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
1614
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
1368
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
4039
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
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.