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. Storing Application Settings

Storing Application Settings

Scheduled Pinned Locked Moved C#
csharpquestion
3 Posts 3 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.
  • M Offline
    M Offline
    mail572352
    wrote on last edited by
    #1

    What's the best way of storing an application setting to read it later? Do I have to resort to a text file or is there some better way with .NET 2.0?

    K B 2 Replies Last reply
    0
    • M mail572352

      What's the best way of storing an application setting to read it later? Do I have to resort to a text file or is there some better way with .NET 2.0?

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      I would store them in the app.config file. // Get the application configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); ///Make changes to the config file. Perhaps in someplace like appSettings //then save config.Save(); Hope that helps. Ben

      1 Reply Last reply
      0
      • M mail572352

        What's the best way of storing an application setting to read it later? Do I have to resort to a text file or is there some better way with .NET 2.0?

        B Offline
        B Offline
        BoneSoft
        wrote on last edited by
        #3

        Depends on your needs. If it's simple data, use an App.config or the Web.config if you're doing a web app. You can just add keys to them which are easy enough to retrieve.

        <configuration>
        <appSettings>
        <add key="field" value="1" />
        </appSettings>
        ...
        </configuration>

        Then in code you can access them with something like...

        string field = System.Configuration.ConfigurationSettings.AppSettings("field");

        But if you have more complex data that you need to store, I usually do my own XML structure and use something like Skeleton Crew[^] to build a code model to use it with.


        Try code model generation tools at BoneSoft.com.

        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