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