By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Best way for Saving User Preferences?

P: n/a
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
Share this Question
Share on Google+
11 Replies


P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a


--

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.