write to app.config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dale

    write to app.config file

    I am trying store and update some variables/options that
    the user can set and that need to be saved and used each
    time the program is run. I am thinking that they should
    be stored in the app.config file and also changed there
    when the user modifies these options.

    My question is does this sound right and is there a
    variable that will give me the path to the app.config
    file?

    Thanks in advance.

  • Cor

    #2
    Re: write to app.config file

    Hi Dale,

    I think that for what you ask are two nice sollutions,
    Make your own "config" XML file using a XML dataset
    or
    The registry
    Both is very easy to do with VB.net

    I hope this helps,

    Cor

    "> I am trying store and update some variables/options that[color=blue]
    > the user can set and that need to be saved and used each
    > time the program is run. I am thinking that they should
    > be stored in the app.config file and also changed there
    > when the user modifies these options.
    >
    > My question is does this sound right and is there a
    > variable that will give me the path to the app.config
    > file?
    >[/color]


    Comment

    • Codemonkey

      #3
      Re: write to app.config file

      [color=blue]
      > I am thinking that they should
      > be stored in the app.config file and also changed there
      > when the user modifies these options.[/color]

      AFAIK, the App.config file is used to store settings that only the
      administrator has access to and therefore should not be written to by the
      applicatin directly. Also, if you write settings to this file, the settings
      will be global to the machine, not local to the specific user.

      Alternatives include:

      Writing to the registry
      Writing to an ini or xml file which is stored in the "ApplicationDat a"
      special folder
      Use Isolated Storage

      Hope this helps,

      Trev.



      "dale" <anonymous@disc ussions.microso ft.com> wrote in message
      news:094201c3d5 1b$7ba12ee0$a60 1280a@phx.gbl.. .[color=blue]
      > I am trying store and update some variables/options that
      > the user can set and that need to be saved and used each
      > time the program is run. I am thinking that they should
      > be stored in the app.config file and also changed there
      > when the user modifies these options.
      >
      > My question is does this sound right and is there a
      > variable that will give me the path to the app.config
      > file?
      >
      > Thanks in advance.
      >[/color]


      Comment

      • William Ryan

        #4
        Re: write to app.config file

        This is an example on how to create keys and get their values from an
        app.config file http://www.knowdotnet.com/articles/configfiles.html
        However, if you want to edit it, you can't do it programatically , you need
        to fire up and editor and do it there.

        Cor and Codemonkey are correct and an easy way to do what you want is either
        the registry or an XML File. As easy as it is to create serializable
        objects in .NET, particulalry with the SOAP formatter for instance, or just
        adding values to a DataSet and using the .WriteXML and .ReadXML methods
        respectively.

        Dan Fergus and Larry Roof wrote a book The Definitive Guide to the Compact
        Framework which has a great example of it (the CF has not native access to
        the registry and doesn't support .config files)...

        HTH,

        Bill
        "dale" <anonymous@disc ussions.microso ft.com> wrote in message
        news:094201c3d5 1b$7ba12ee0$a60 1280a@phx.gbl.. .[color=blue]
        > I am trying store and update some variables/options that
        > the user can set and that need to be saved and used each
        > time the program is run. I am thinking that they should
        > be stored in the app.config file and also changed there
        > when the user modifies these options.
        >
        > My question is does this sound right and is there a
        > variable that will give me the path to the app.config
        > file?
        >
        > Thanks in advance.
        >[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: write to app.config file

          * "dale" <anonymous@disc ussions.microso ft.com> scripsit:[color=blue]
          > I am trying store and update some variables/options that
          > the user can set and that need to be saved and used each
          > time the program is run. I am thinking that they should
          > be stored in the app.config file and also changed there
          > when the user modifies these options.[/color]

          Storing "user preferences" is not the purpose of config files.

          Configuration Management Application Block
          <http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dnbda/html/cmab.asp>

          <http://www.palmbytes.d e/content/dotnetlibs/optionslib.htm>

          --
          Herfried K. Wagner [MVP]
          <http://www.mvps.org/dotnet>

          Comment

          Working...