where to save app settings?

  • Thread starter Thread starter Sam Carleton
  • Start date Start date
S

Sam Carleton

It is my understanding that in .Net the registry is not the
prefered place to save application settings. What has Microsoft
put in place to replace it? I thought it was the .config file,
but I am unable to figure out how to write to the file.

Sam
 
Hi Sam,

Using .config files is the popular way of storing configuration infomation.

Note that the .config file of an app is read only the first time it is
loaded - any further changes you make to the .config file will not be
reflected in the app, and therefore, will be read only on read in the next
run of the app.

Also check out:
http://www.grimes.demon.co.uk/dotnet/configFAQ.htm

HTH,
Rakesh Rajan
 
The .config file is the prefered place to store application settings.
However, they should not be changed by the application.

User configured settings should be saved to the user's folder (use
Environment.SpecialFolder.ApplicationData or
Environment.SpecialFolder.LocalApplicationData) - NOT the application
folder, where the .config file is.
A simple way to store user settings is create a class to hold all of
your settings and the serialize it to an XML file in the special folder.
You then de-serialize the file to restore the settings.
 
Sam Carleton said:
It is my understanding that in .Net the registry is not the
prefered place to save application settings. What has Microsoft
put in place to replace it? I thought it was the .config file,
but I am unable to figure out how to write to the file.

The .config file is for application settings, not user settings. For user
settings, you probably want to save the data in "Isolated Storage". You can
go to www.genghisgroup.com where you will find a free set of tools that
includes a Preferences class that saves user preferences in Isolated
Storage.
 
See the Enterprise Library, a seperate download from MS
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/entlib.asp

The configuration application block will allow you to read and write
configuration settings. Even though the design of this AB is highly
flexible and extensible, you do not need to create new storage provider to
use the XML config files.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top