473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Best way for Saving User Preferences?

Tom
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom

Nov 21 '05 #1
11 2387
http://msdn.microsoft.com/library/de.../html/cmab.asp

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom

Nov 21 '05 #2
Tom
Terry: Your answer leaves me with even more questions. For instance, I
already use the CMAB in my application to read a 'base' settings file that I
use to supply control settings. These settings come from a server file and
are NOT changed by the user - only myself. As I see it, the CMAB cannot read
anything but the MyApp.exe.config file (i.e. I would want the actual user
preferences settings stored in another XML file such as AppSettings.xml -
and the CMAB cannot be told to 'read' this file instead).

Also, even if I did use the CMAB, are you saying that the best way would be
to manually populate the CMAB? Remember, I am going to use a Property Grid
to interface the settings to the user. Would not simply serializing the
class that I 'bind' to the Property Grid suffice? Or are there bigger issues
to this?

Don't get the wrong idea - I am open to using the CMAB. I just don't see any
way for it to read anything but the base config file, and since I use that
file to supply hard-coded info to my users, I can't use it to store user
preferences. Again, not trying to answer my own question, but just curious
of the various ways I could do this (and what would be the most logical).
Thanks.

Tom
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:ed*************@TK2MSFTNGP11.phx.gbl...
http://msdn.microsoft.com/library/de.../html/cmab.asp
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle or making the user ditch all their preferences and start over).

Thoughts?

Tom


Nov 21 '05 #3
"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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???


Tom,

There are several good ideas in this MSDN Mag. article:
http://msdn.microsoft.com/msdnmag/is...s/default.aspx

It discusses using isolated storage, registery, etc... I personally like
using XML because it's so much more portable and expandable than other
storage (INI, IS or Registry). Also, I usually use the XML Serializer and
create objects to represent the settings. But that's just my preference.

Whatever you do, the key points to keep in mind are storage, run-time
representation, and presentation to the user (in conjunction with how the
settings are stored).

Jeremy
Nov 21 '05 #4


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
Terry: Your answer leaves me with even more questions. For instance, I
already use the CMAB in my application to read a 'base' settings file that I use to supply control settings. These settings come from a server file and
are NOT changed by the user - only myself. As I see it, the CMAB cannot read anything but the MyApp.exe.config file (i.e. I would want the actual user
preferences settings stored in another XML file such as AppSettings.xml -
and the CMAB cannot be told to 'read' this file instead).

Also, even if I did use the CMAB, are you saying that the best way would be to manually populate the CMAB? Remember, I am going to use a Property Grid
to interface the settings to the user. Would not simply serializing the
class that I 'bind' to the Property Grid suffice? Or are there bigger issues to this? What types of data can I store?
The Configuration Management Application Block provides support for storing
application configuration data contained in Hashtable objects as well as any
data type supported by the XmlSerializer class. In addition, the extensible
architecture of the Configuration Management Application Block means that
you can easily add support for any data structure with minimal development
effort.

HTH

Don't get the wrong idea - I am open to using the CMAB. I just don't see any way for it to read anything but the base config file, and since I use that
file to supply hard-coded info to my users, I can't use it to store user
preferences. Again, not trying to answer my own question, but just curious
of the various ways I could do this (and what would be the most logical).
Thanks.

Tom
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:ed*************@TK2MSFTNGP11.phx.gbl...

http://msdn.microsoft.com/library/de.../html/cmab.asp

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle or making the user ditch all their preferences and start over).

Thoughts?

Tom



Nov 21 '05 #5
I haven't used CMAB much, but I quickly discovered it does NOT handle user
preferences out of the box. In other words, it does not store the xml file
to a user's profile folder. It can be modified to do so, but so much for
plug n play.

just my .02
Greg
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uC*************@TK2MSFTNGP11.phx.gbl...


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
Terry: Your answer leaves me with even more questions. For instance, I
already use the CMAB in my application to read a 'base' settings file
that

I
use to supply control settings. These settings come from a server file
and
are NOT changed by the user - only myself. As I see it, the CMAB cannot

read
anything but the MyApp.exe.config file (i.e. I would want the actual user
preferences settings stored in another XML file such as AppSettings.xml -
and the CMAB cannot be told to 'read' this file instead).

Also, even if I did use the CMAB, are you saying that the best way would

be
to manually populate the CMAB? Remember, I am going to use a Property
Grid
to interface the settings to the user. Would not simply serializing the
class that I 'bind' to the Property Grid suffice? Or are there bigger

issues
to this?

What types of data can I store?
The Configuration Management Application Block provides support for
storing
application configuration data contained in Hashtable objects as well as
any
data type supported by the XmlSerializer class. In addition, the
extensible
architecture of the Configuration Management Application Block means that
you can easily add support for any data structure with minimal development
effort.

HTH

Don't get the wrong idea - I am open to using the CMAB. I just don't see

any
way for it to read anything but the base config file, and since I use
that
file to supply hard-coded info to my users, I can't use it to store user
preferences. Again, not trying to answer my own question, but just
curious
of the various ways I could do this (and what would be the most logical).
Thanks.

Tom
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:ed*************@TK2MSFTNGP11.phx.gbl...
>

http://msdn.microsoft.com/library/de.../html/cmab.asp
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Tom" <to*@nospam.com> wrote in message
> news:Or**************@TK2MSFTNGP11.phx.gbl...
> > 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... want a way that is easy
> > and
> > flexible (i.e. can add/remove preferences later on without a lot of

hassle
> > or making the user ditch all their preferences and start over).
> >
> > Thoughts?
> >
> > Tom
> >
> >
> >
>
>



Nov 21 '05 #6
I think you will find that will most applications blocks they are a bit
'Full' of code and posibility, but sometimes can be a bit over the top. If
the OP just wants simple unsecure storage then a serialized output will do.
Isolated storage is another option but truly is a bit weird to work wotk.
Other than that there is allways the registry, or an SQL ( or like )
database storage as a possibility.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eG**************@TK2MSFTNGP15.phx.gbl...
I haven't used CMAB much, but I quickly discovered it does NOT handle user
preferences out of the box. In other words, it does not store the xml file to a user's profile folder. It can be modified to do so, but so much for
plug n play.

just my .02
Greg
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uC*************@TK2MSFTNGP11.phx.gbl...


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Tom" <to*@nospam.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...
Terry: Your answer leaves me with even more questions. For instance, I
already use the CMAB in my application to read a 'base' settings file
that

I
use to supply control settings. These settings come from a server file
and
are NOT changed by the user - only myself. As I see it, the CMAB cannot

read
anything but the MyApp.exe.config file (i.e. I would want the actual user preferences settings stored in another XML file such as AppSettings.xml - and the CMAB cannot be told to 'read' this file instead).

Also, even if I did use the CMAB, are you saying that the best way would
be
to manually populate the CMAB? Remember, I am going to use a Property
Grid
to interface the settings to the user. Would not simply serializing the
class that I 'bind' to the Property Grid suffice? Or are there bigger

issues
to this?

What types of data can I store?
The Configuration Management Application Block provides support for
storing
application configuration data contained in Hashtable objects as well as
any
data type supported by the XmlSerializer class. In addition, the
extensible
architecture of the Configuration Management Application Block means that
you can easily add support for any data structure with minimal development effort.

HTH

Don't get the wrong idea - I am open to using the CMAB. I just don't
see any
way for it to read anything but the base config file, and since I use
that
file to supply hard-coded info to my users, I can't use it to store

user preferences. Again, not trying to answer my own question, but just
curious
of the various ways I could do this (and what would be the most logical). Thanks.

Tom
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:ed*************@TK2MSFTNGP11.phx.gbl...
>

http://msdn.microsoft.com/library/de.../html/cmab.asp
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Tom" <to*@nospam.com> wrote in message
> news:Or**************@TK2MSFTNGP11.phx.gbl...
> > 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... want a way that is easy
> > and
> > flexible (i.e. can add/remove preferences later on without a lot of
hassle
> > or making the user ditch all their preferences and start over).
> >
> > Thoughts?
> >
> > Tom
> >
> >
> >
>
>



Nov 21 '05 #7
Here's one possibility

http://msdn.microsoft.com/vbasic/usi...et07082003.asp

Another is to use the CMAB. In that case, it is best to create a custom
XmlFileStorage provider that does token replacement for %ApplicationData% in
the "path" value - replacing it with
System.Environment.GetFolderPath(System.Environmen t.SpecialFolder.ApplicationData).
You'll also need to alter it to create an empty file if one doesn't exist.
These changes are made in the Init method of the class.

Rocky
--
Rockford Lhotka
Microsoft Software Legend, Regional Director and MVP
Author of the Expert VB.NET & C# Business Objects books
ro***@lhotka.net http://www.lhotka.net
"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom

Nov 21 '05 #8
I did suggest this but it was frowned upon.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Rockford Lhotka" <ro*********@NOSPAMlhotka.net> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
Here's one possibility

http://msdn.microsoft.com/vbasic/usi...et07082003.asp
Another is to use the CMAB. In that case, it is best to create a custom
XmlFileStorage provider that does token replacement for %ApplicationData% in the "path" value - replacing it with
System.Environment.GetFolderPath(System.Environmen t.SpecialFolder.Applicatio
nData). You'll also need to alter it to create an empty file if one doesn't exist.
These changes are made in the Init method of the class.

Rocky
--
Rockford Lhotka
Microsoft Software Legend, Regional Director and MVP
Author of the Expert VB.NET & C# Business Objects books
ro***@lhotka.net http://www.lhotka.net
"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle or making the user ditch all their preferences and start over).

Thoughts?

Tom


Nov 21 '05 #9
http://www.kjmsolutions.com/xmlsettings.htm

"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl:
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of
hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom


Nov 21 '05 #10
Tom
All: Just wanted to say THANKS for all the messages and help. I decided to
go with saving the preferences directly serialized to an XML file. I have a
separate class object that contains all my preferences settings; then I
'simply' serialize/deserialize that when needed. Works out great....

Thanks again for all your suggestions!

Tom

"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom

Nov 21 '05 #11
This sounds like the way I want to go. I can probably modify the
XmlFileStorage provider as you describe, but thought I'd ask if you have some
code snippets where you've already done this. I'd prefer not to reinvent the
wheel. Of course, I already am indebted to you for the suggestion on how to
accomplish this feature, so Thanks Already!

"Rockford Lhotka" wrote:
Here's one possibility

http://msdn.microsoft.com/vbasic/usi...et07082003.asp

Another is to use the CMAB. In that case, it is best to create a custom
XmlFileStorage provider that does token replacement for %ApplicationData% in
the "path" value - replacing it with
System.Environment.GetFolderPath(System.Environmen t.SpecialFolder.ApplicationData).
You'll also need to alter it to create an empty file if one doesn't exist.
These changes are made in the Init method of the class.

Rocky
--
Rockford Lhotka
Microsoft Software Legend, Regional Director and MVP
Author of the Expert VB.NET & C# Business Objects books
ro***@lhotka.net http://www.lhotka.net
"Tom" <to*@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
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... want a way that is easy and
flexible (i.e. can add/remove preferences later on without a lot of hassle
or making the user ditch all their preferences and start over).

Thoughts?

Tom


Nov 21 '05 #12

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

Similar topics

7
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...
0
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...
2
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...
2
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...
15
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...
2
by: S. Olivier | last post by:
Hey folks, I converted an INI file to use app.config in VB.NET. I can read the settings at runtime with ConfigurationSettings.AppSettings and work well, but is it possible to write a new value at...
6
by: RS | last post by:
Hi, What's the best practice to save user preferences for a .NET application . For example if the user does not want anymore to see Tip-Of-The-Day (TOTD), the user can tick a checkbox on the...
1
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...
2
by: Tal Shachar | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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...

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.