473,794 Members | 3,056 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving user preferences

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
Feb 17 '07 #1
2 2936
On Sat, 17 Feb 2007 22:40:00 +0200, "Tal Shachar" <ta*********@ho tmail.com>
wrote:
>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
Feb 18 '07 #2
On Sun, 18 Feb 2007 10:31:40 +0800, Otis Mukinfus
<ph************ ******@phoney.c omwrote:
On Sat, 17 Feb 2007 22:40:00 +0200, "Tal Shachar"
<ta*********@ho tmail.com>
>[...]
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.Sett ings.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
Feb 27 '07 #3

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

Similar topics

7
2497
by: Brian Wallis | last post by:
This may be a FAQ,but I cannot find it. I want to save user preferences, window sizes, recently opened file names, etc for a python application and I am looking for a package that does this in a way that is portable across unix/linux and windows (and mac would be nice as well). Is there a 'standard' package for doing this in python? thanks,
0
1855
by: Adam J. Schaff | last post by:
OK, there are billions of posts on dotnet newsgroups about this, and I have read half of them, but I'm still a little confused. First I'll say what I think I've learned and anyone can correct me if I'm off target. 1. User preferences should be saved to the UserAppDataPath. 2. They should be saved as an XML file. 3. Serialization is a handy technology for going about this, since you can simply store all your preferences in an object and...
2
2277
by: Nevyn Twyll | last post by:
I understand that I am not supposed to alter the .config file for a program (accessible through the AppSettings). Is there a System class you could recommend that I could use (or even a class out there somewhere) to easily load and save custom settings for the current user? My only thought is to maybe use a datatable with "key" and "value" columns and serialize it through XML in an IsolatedStorageFile - but this just seems so lame and...
2
1995
by: VS Noob | last post by:
Hello. I'm developing Windows.Forms based applications, and each will need per-user persistent data consisting of user preferences, last form size/position, and the like. Is there a standard or recommended approach to this? I'm aware that such data is often stored in an appropriate HKCU\Software subkey and/or Application Data subfolder. What I haven't figured out yet is if there is some convenient ..Net component or mechanism which...
15
1520
by: Dan DeConinck | last post by:
Hello, I want to save the position of all the controls on my form. I would like to write them out to a preference file. I have done this in DOS BASIC like this: TO WRITE the preference open "c:\preferences.txt" for input as #1 input #1 ,a,b,c
0
973
by: Tom | last post by:
I am planning on adding a Preferences form to my application and using the Property Grid to display the preferences to the user. What do you think would be the best way to save these preferences out to an XML file? Use the CAB (Configuration Application Block)? Save the preferences in a class object and serialize them out the the XML file? Write them out directly to the XML file? Other ways??? Just want to get some thoughts together......
11
2431
by: Tom | last post by:
I am planning on adding a Preferences form to my application and using the Property Grid to display the preferences to the user. What do you think would be the best way to save these preferences out to an XML file? Use the CAB (Configuration Application Block)? Save the preferences in a class object and serialize them out the the XML file? Write them out directly to the XML file? Other ways??? Just want to get some thoughts together......
1
1634
by: Tom | last post by:
I have a large application; lots of forms, multiple dynamic DLLs, etc. I also have, in the appliation, a general 'Preferences' class object (which is in itself a separate DLL, and I just include a reference to it so I can instantiate it at the beginning) which stores all my user preferences. I serialize the data to and from an XML file, thereby saving and restoring the user preferences with ease. I also have a Preferences form that the user...
1
1314
by: sonic | last post by:
so, profile provider is a way to save application preferenes for each user. the profile can be replaced to provide a different persistance layer, and/or schema, but what about tweaking it to work in page level, to save preferences for all controls on each page for example. in a application with 100's of sites, containing many of the same controls, i'd like to be able to persist different states of controls depending on the page, and also...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9037
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.