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. Configuration file for data inputs.

Configuration file for data inputs.

Scheduled Pinned Locked Moved C#
csharpquestionworkspace
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.
  • A Offline
    A Offline
    AksharRoop
    wrote on last edited by
    #1

    Hi All, I wrote an application that reads web page contents and send to specified email addresses. I want to make this configurable; i mean a user should be able to set/change at anytime the to,from,subject etc. details. I am new to C# but i know that app.config is one way to do this, but what i have read in forums that people generally use it only for installation configs. Is there any other way where a user would be able to provide input in key-value format? Thanks, AksharRoop

    S D 2 Replies Last reply
    0
    • A AksharRoop

      Hi All, I wrote an application that reads web page contents and send to specified email addresses. I want to make this configurable; i mean a user should be able to set/change at anytime the to,from,subject etc. details. I am new to C# but i know that app.config is one way to do this, but what i have read in forums that people generally use it only for installation configs. Is there any other way where a user would be able to provide input in key-value format? Thanks, AksharRoop

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      Add a "Settings" file (using the VS add new item option), name it something like "MySettings" Open it up and add your various different settings, set a type for them, and provide default values. (Make sure they are set to "application" scope not "user". In you program you can read the values by doing MySettings.Default.MySettingValue. When you compile your app you'll find the defaults are added to the app.config file. in the bin\debug\ directory you can edit the exename.config file and make changes. when you run it, it will use the value from the .config file. (The default values are actually also compiled into the assembly, so if you delete the exename.config file, or remove any values it will still revert to the default ones that are compiled into the assembly.) Alternatively, if you set the settings to "user" mode, you will be able to write changes to them in code, and call MySettings.Default.Save() to save the changes to a user.config file that is stored in "c:\documents and settings\username\localsettings\application data\appname\appversion\user.config". If you did this you would also need to provide a configuration form for the user to enter their values and hit save.

      Simon

      1 Reply Last reply
      0
      • A AksharRoop

        Hi All, I wrote an application that reads web page contents and send to specified email addresses. I want to make this configurable; i mean a user should be able to set/change at anytime the to,from,subject etc. details. I am new to C# but i know that app.config is one way to do this, but what i have read in forums that people generally use it only for installation configs. Is there any other way where a user would be able to provide input in key-value format? Thanks, AksharRoop

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

        Use the application settings. Project|Properties|Settings. Create any fields you need making sure the scope is User. You can then recall these using Properties.Settings.Default._YourSettingName_ and saved using Properties.Settings.Default.Save();

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        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