Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Best way for Saving User Preferences?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 28 Sep 2004 13:14 GMT
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
One Handed Man \( OHM - Terry Burns \) - 28 Sep 2004 13:55 GMT
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/cmab.asp

Signature

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

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

> 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
[quoted text clipped - 10 lines]
>
> Tom
Tom - 28 Sep 2004 15:14 GMT
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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/cmab.asp

> > 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
[quoted text clipped - 11 lines]
> >
> > Tom
One Handed Man \( OHM - Terry Burns \) - 28 Sep 2004 15:33 GMT
Signature

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

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

> 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
[quoted text clipped - 9 lines]
> 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
[quoted text clipped - 4 lines]
>
> Tom

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/cmab.asp

> > > I am planning on adding a Preferences form to my application and using
> the
[quoted text clipped - 14 lines]
> > >
> > > Tom
Greg Burns - 28 Sep 2004 15:37 GMT
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

>> 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
[quoted text clipped - 71 lines]
>> > >
>> > > Tom
One Handed Man \( OHM - Terry Burns \) - 28 Sep 2004 17:43 GMT
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.

Signature

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

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

> 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
[quoted text clipped - 52 lines]
> > message
> >> news:edEh9pVpEHA.324@TK2MSFTNGP11.phx.gbl...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/cmab.asp

> >> > > I am planning on adding a Preferences form to my application and
> >> > > using
[quoted text clipped - 20 lines]
> >> > >
> >> > > Tom
Jeremy - 28 Sep 2004 15:23 GMT
>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
[quoted text clipped - 3 lines]
> 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/issues/04/07/CustomPreferences/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
Rockford Lhotka - 28 Sep 2004 17:50 GMT
Here's one possibility

http://msdn.microsoft.com/vbasic/using/columns/adventures/default.aspx?pull=/lib
rary/en-us/dnadvnet/html/vbnet07082003.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.Environment.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
Signature

Rockford Lhotka
Microsoft Software Legend, Regional Director and MVP
Author of the Expert VB.NET & C# Business Objects books
rocky@lhotka.net    http://www.lhotka.net

>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
[quoted text clipped - 11 lines]
>
> Tom
One Handed Man \( OHM - Terry Burns \) - 28 Sep 2004 17:57 GMT
I did suggest this but it was frowned upon.

Signature

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

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

> Here's one possibility

http://msdn.microsoft.com/vbasic/using/columns/adventures/default.aspx?pull=/lib
rary/en-us/dnadvnet/html/vbnet07082003.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.Environment.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.
[quoted text clipped - 15 lines]
> >
> > Tom
Bill Hertzing - 19 Oct 2004 14:17 GMT
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!

> Here's one possibility
>
[quoted text clipped - 23 lines]
> >
> > Tom
scorpion53061 - 28 Sep 2004 18:55 GMT
http://www.kjmsolutions.com/xmlsettings.htm

> I am planning on adding a Preferences form to my application and using
> the
[quoted text clipped - 14 lines]
>
> Tom
Tom - 05 Oct 2004 17:33 GMT
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

> 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
[quoted text clipped - 10 lines]
>
> Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.