|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to read Default Values from App.Config for User Settings?How can I read default values for user settings from the app.config file? I've seen someone mention using the .DefaultSettingValueAttribute and reflection, but I don't know how to use them. I am trying to do the following: 1) Create a simple Windows App that has one user setting named "SupportAddress" and a default (string) value. 2) The default support address is in the App.Config file. 3) Make a form which allows users to modify and save the setting. This creates the User.Config file in the Application Data folder. 4) This I don't know - If the users mess up the support address value, I want to allow them to read the default value for the SupportAddress setting from the App.Config, not from the User.Config file. Of course, there will be a button named "Revert to Default" or similar on the form. What should I do? Thanks in advance, Djordje sample contents of the Config file.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="SupportAddress" value="theDefaultValue"/> </appSettings> </configuration> //code to read the SupportAddress AppSettingsReader settingsReader = new AppSettingsReader(); string default = settingsReader.GetValue("SupportAddress", typeof(string)).ToString(); =================== Clay Burch Syncfusion, Inc.
Other interesting topics
Databind a nullable date to a masked textbox
Graphics dpi not correct This code compiles/runs but breaks designer... How to capture keystroke Problems with BackGroundWorker Is it possible to set a TextRenderingHint for an entire appplication? Adding an event handler to a dynamically populated control Datagridview help Newbie question: how to set focus to a usercontrol print the current time on the screen |
|||||||||||||||||||||||