Best way for Saving User Preferences?

Discussion in 'Microsoft VB .NET' started by Tom, Sep 28, 2004.

  1. Tom

    Tom Guest

    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
     
    Tom, Sep 28, 2004
    #1
    1. Advertisements

  2. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/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" <> wrote in message
    news:...
    > 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 \), Sep 28, 2004
    #2
  3. Tom

    Tom Guest

    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:...
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/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" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
     
    Tom, Sep 28, 2004
    #3
  4. Tom

    Jeremy Guest

    "Tom" <> wrote in message
    news:...
    >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/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
     
    Jeremy, Sep 28, 2004
    #4
  5. --

    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" <> wrote in message
    news:...
    > 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:...
    > >

    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/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" <> wrote in message
    > > news:...
    > > > 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 \), Sep 28, 2004
    #5
  6. Tom

    Greg Burns Guest

    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:...
    >
    >
    > --
    >
    > 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" <> wrote in message
    > news:...
    >> 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:...
    >> >

    >>

    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/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" <> wrote in message
    >> > news:...
    >> > > 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
    >> > >
    >> > >
    >> > >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Greg Burns, Sep 28, 2004
    #6
  7. 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:...
    > 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:...
    > >
    > >
    > > --
    > >
    > > 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" <> wrote in message
    > > news:...
    > >> 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:...
    > >> >
    > >>

    > >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/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" <> wrote in message
    > >> > news:...
    > >> > > 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 \), Sep 28, 2004
    #7
  8. Here's one possibility

    http://msdn.microsoft.com/vbasic/us...library/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
    --
    Rockford Lhotka
    Microsoft Software Legend, Regional Director and MVP
    Author of the Expert VB.NET & C# Business Objects books
    http://www.lhotka.net


    "Tom" <> wrote in message
    news:...
    >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
    >
    >
    >
     
    Rockford Lhotka, Sep 28, 2004
    #8
  9. 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" <> wrote in message
    news:...
    > Here's one possibility
    >
    >

    http://msdn.microsoft.com/vbasic/us...library/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.
    >
    > Rocky
    > --
    > Rockford Lhotka
    > Microsoft Software Legend, Regional Director and MVP
    > Author of the Expert VB.NET & C# Business Objects books
    > http://www.lhotka.net
    >
    >
    > "Tom" <> wrote in message
    > news:...
    > >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 \), Sep 28, 2004
    #9
  10. http://www.kjmsolutions.com/xmlsettings.htm



    "Tom" <> wrote in message
    news::
    > 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
     
    scorpion53061, Sep 28, 2004
    #10
  11. Tom

    Tom Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    >
     
    Tom, Oct 5, 2004
    #11
  12. Tom

    Guest Guest

    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/us...library/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
    > --
    > Rockford Lhotka
    > Microsoft Software Legend, Regional Director and MVP
    > Author of the Expert VB.NET & C# Business Objects books
    > http://www.lhotka.net
    >
    >
    > "Tom" <> wrote in message
    > news:...
    > >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
    > >
    > >
    > >

    >
    >
    >
     
    Guest, Oct 19, 2004
    #12

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Larry Woods
    Replies:
    16
    Views:
    837
    Herfried K. Wagner [MVP]
    Sep 1, 2003
  2. Tom

    Saving Property Grid Preferences

    Tom, Sep 21, 2004, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    181
  3. Tom
    Replies:
    1
    Views:
    187
    Brad Shook
    Oct 19, 2004
  4. Guest

    Saving user preferences between sessions.

    Guest, Jan 24, 2005, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    191
    Guest
    Jan 25, 2005
  5. RS
    Replies:
    6
    Views:
    237
    Doug Taylor
    May 13, 2005
Loading...

Share This Page