Click to See Complete Forum and Search --> : settings.settings == app.config ??


memeloo
September 3rd, 2009, 04:37 AM
there are some texts around that say setting files are better then app.config. but this seems not to be the truth. I've just created one settings file and everything I wrote in the designer was saved in the app.config files. so this is not a big advantage after all. it's only some kind of a wrapper for the app.config.

boudino
September 3rd, 2009, 06:03 AM
Just wrapper, but usefull, because it is strongly typed and you can access the config values trought properties instead generic string keys.

eclipsed4utoo
September 3rd, 2009, 08:37 AM
If you are referring to the "Properties.Settings.Default", this is completely different from the app.config file. They are stored in two completely different places.

One downside of using the Properties.Settings.Default is that the file is specific for the assembly version. So if you change your assembly version, then it uses a different file and you lose any settings that were saved for the previous assembly version. Though there are ways to get around this.

memeloo
September 3rd, 2009, 10:48 AM
If you are referring to the "Properties.Settings.Default", this is completely different from the app.config file. They are stored in two completely different places.

could you tell me where?

One downside of using the Properties.Settings.Default is that the file is specific for the assembly version. So if you change your assembly version, then it uses a different file and you lose any settings that were saved for the previous assembly version. Though there are ways to get around this.
I've got exacly this proplem in my app. I'd appriciate some clues how to get around this.

Arjay
September 3rd, 2009, 11:32 AM
See Application.LocalUserAppDataPath (http://msdn.microsoft.com/en-us/library/system.windows.forms.application.localuserappdatapath(VS.80).aspx)

&

http://msdn.microsoft.com/en-us/library/0zszyc6e.aspx

BigEd781
September 3rd, 2009, 12:00 PM
As an aside, I have encountered problems using the built in settings file. It seems that if the file is missing an exception will be thrown before main() is entered. I had to write my own settings class to avoid this.

eclipsed4utoo
September 3rd, 2009, 12:17 PM
the physical path is:

C:\Documents and Settings\[username]\Local Settings\Application Data\[AssemblyCompanyName]\[NameOfProject].[SomeLongUniqueString]\[AssemblyVersion]\user.config

that's in XP.

memeloo
September 7th, 2009, 04:51 AM
ok, now I know where each file is stored and I read the msdn-pages about settings but I didn't find how to prevent a new version of my app to overwrite the old settings.

eclipsed4utoo
September 8th, 2009, 07:06 AM
when you change the assembly version of your application, it does NOT overwrite the old settings. If you notice in the path that I posted, the last directory is the Assembly Version. If you change the assembly version, the app will create a new folder and a new file, and begin using that file. That's how you "lose" your old settings. The old file is still there, it's just in a different directory from where the application is looking for the "user.config" file.