saving user preferences

T

Tal Shachar

Hi,
I have a windows application that needs to save some user preferences to an
xml and to load it on the next application run.
Saving the preferences is done per user.
I know that there is a way of saving it to some path under "Documents and
Settings/UserName/...." , but I don't know the correct approach (e.g. path
naming convention, how to preserve this per user, etc.)
I can use all the assistance I can get (code snippets and some explanations
will be well appreciated...)

TIA,

- Tal
 
O

Otis Mukinfus

Hi,
I have a windows application that needs to save some user preferences to an
xml and to load it on the next application run.
Saving the preferences is done per user.
I know that there is a way of saving it to some path under "Documents and
Settings/UserName/...." , but I don't know the correct approach (e.g. path
naming convention, how to preserve this per user, etc.)
I can use all the assistance I can get (code snippets and some explanations
will be well appreciated...)

TIA,

- Tal
Visual Studio is your friend...

In VS 2005, in the Help index search text box enter Application Settings. You
will be presented with a long list of topics.

Good luck with your project,

Otis Mukinfus

http://www.otismukinfus.com
http://www.arltex.com
http://www.tomchilders.com
http://www.n5ge.com
 
P

Peter Duniho

On Sat, 17 Feb 2007 22:40:00 +0200, "Tal Shachar"
[...]
I have a windows application that needs to save some user preferences
to an xml and to load it on the next application run.
Saving the preferences is done per user.
I know that there is a way of saving it to some path under "Documents
and Settings/UserName/...." , but I don't know the correct approach
[...]

Visual Studio is your friend...

In VS 2005, in the Help index search text box enter Application
Settings. You will be presented with a long list of topics.

The short answer is that you can add items to the project's "Settings".
You then access them from code using the Properties.Settings.Default
property. You can create default values in your project, retrieve and set
the values from code, and save them back out. .NET will deal with the
issues of where to actually store the settings and how to format the
storage file (it's an XML file, with individual settings generally being
stored as strings that are converted to and from the proper data types as
necessary).

I have found that just exploring the project and its settings in VS is
sufficient for learning the basic techniques, but if you still find
yourself lost, I agree with Otis that the help index can find you the
necessary articles in the .NET documentation.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top