Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Application configuration?

Application configuration?

Scheduled Pinned Locked Moved C#
helptutorialcsharpquestionworkspace
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dophka
    wrote on last edited by
    #1

    I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it. My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file. Is there any simple way to arrange custom configuration and read-write it? Can someone share a simple understandable example of it? I hope I explained it clear enough. Thank you all.

    K H Z A 4 Replies Last reply
    0
    • D dophka

      I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it. My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file. Is there any simple way to arrange custom configuration and read-write it? Can someone share a simple understandable example of it? I hope I explained it clear enough. Thank you all.

      K Offline
      K Offline
      Kannan Kalyanaraman
      wrote on last edited by
      #2

      Take a look at the "Isolated Storage" in the docs and also have a look at this[^] article. Regards, Kannan

      D 1 Reply Last reply
      0
      • K Kannan Kalyanaraman

        Take a look at the "Isolated Storage" in the docs and also have a look at this[^] article. Regards, Kannan

        D Offline
        D Offline
        dophka
        wrote on last edited by
        #3

        I guess this might help and I am trying to read the article. However, the code in the article looks bit complicated. Can you (someone) maybe give me a simple example of reading/writing a couple of settings? like nick : real name? thanks a lot lot lot!

        1 Reply Last reply
        0
        • D dophka

          I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it. My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file. Is there any simple way to arrange custom configuration and read-write it? Can someone share a simple understandable example of it? I hope I explained it clear enough. Thank you all.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          The .config file is just an XML file, so use the System.Xml namespace elements to append/insert/delete your settings. Note that this will not update your configuration options while the process is running. For information on how to do that, search the comments for this forum for keywords like AppDomainSetup because I've already covered how to do this a couple times. Of course, you could always update your settings in the running, cached instance if you provide an instance property for your configuration section object (which the IConfigurationSectionHandler implementation creates) and update your UI accordingly.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          1 Reply Last reply
          0
          • D dophka

            I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it. My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file. Is there any simple way to arrange custom configuration and read-write it? Can someone share a simple understandable example of it? I hope I explained it clear enough. Thank you all.

            Z Offline
            Z Offline
            zuhx
            wrote on last edited by
            #5

            Look at XML serialization. You can create an xml file that contains your app settings. You would simply 1. open a file stream 2. create xml formatter 3. serialize the settings you choose to the xml file. Take a look at serialization. You could use the .config file but this is read only, therefore you cannot create a user interface to modify it.

            H 1 Reply Last reply
            0
            • Z zuhx

              Look at XML serialization. You can create an xml file that contains your app settings. You would simply 1. open a file stream 2. create xml formatter 3. serialize the settings you choose to the xml file. Take a look at serialization. You could use the .config file but this is read only, therefore you cannot create a user interface to modify it.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              And if the config file contained other stuff not for his section? This would NOT be a good idea because the other IConfigurationSectionHandler implementations provided in the .NET BCL do not use XML serialization. XML Serialization would wipe out the file and create a new one (based on your stream preferences).

              -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

              1 Reply Last reply
              0
              • D dophka

                I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it. My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file. Is there any simple way to arrange custom configuration and read-write it? Can someone share a simple understandable example of it? I hope I explained it clear enough. Thank you all.

                A Offline
                A Offline
                Alvaro Mendez
                wrote on last edited by
                #7

                For a simple solution take a look at my Profile article[^]. Regards, Alvaro


                He who laughs last, thinks slowest.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups