Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to Change the settings of an application with User.config
 

How to Change the settings of an application with User.config

Hi
I have created a Windows application in .NET 3.5. I have Created some settings and i know that they are storing it in User.config.

Now wht i want that when i install my application on some other machine the settings should be stored from that user.config file. User should no bither abt again setting the settings for the same app.

Please tell me how can i handle the User.config file dynamically and can store the settings with the help of user.config file on other machine.

PLease........

Progress2007  Friday, September 11, 2009 8:49 AM
The user settings default values established in the Settings properties for the user are also saved as application settings, and become the default user settings for a new installation.

Or, are yourwantingthe user to beable to transfertheir own specific settings from one installation of your application to the next? If so, you need to decide how those settings are going to be physically transferred from the location of the existing installation to the location of the new installation. I imagine that you don't want the user bothering with finding and copying the user.config file. My preference would be to provide an option in the application to "Save current settings to transfer file" and "Load settings from transfer file".The user would still be responsible for finding the transfer file and physically relocating it (if required). You could build in a prompt to (optionally) loadsettings from a transferfile on first run after installation (based on an item in user settings)but the user would still need to specify the name and location of that file.If settings are bound to control properties then simply setting control properties from the data in the ransfer file would ensure they are persisted as user settings. Otherwise, you need to manually update the settings and save them.
Acamar  Sunday, September 13, 2009 12:34 AM
The user settings default values established in the Settings properties for the user are also saved as application settings, and become the default user settings for a new installation.

Or, are yourwantingthe user to beable to transfertheir own specific settings from one installation of your application to the next? If so, you need to decide how those settings are going to be physically transferred from the location of the existing installation to the location of the new installation. I imagine that you don't want the user bothering with finding and copying the user.config file. My preference would be to provide an option in the application to "Save current settings to transfer file" and "Load settings from transfer file".The user would still be responsible for finding the transfer file and physically relocating it (if required). You could build in a prompt to (optionally) loadsettings from a transferfile on first run after installation (based on an item in user settings)but the user would still need to specify the name and location of that file.If settings are bound to control properties then simply setting control properties from the data in the ransfer file would ensure they are persisted as user settings. Otherwise, you need to manually update the settings and save them.
Acamar  Sunday, September 13, 2009 12:34 AM

Hi Progress2007 ,

Based on my understanding, you want to fetch some setting of user scope and persist them to the User.config file, so that this configuration can be reused by others. Please feel free to tell me if I misunderstand you.

If so, we need to get the values of these settings and write them to the User.config file programmatically via XmlDocument. The thread below shows how to pass values to a .config file: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/cb9b4823-1dc4-4721-9797-f65bd0de6135.

Let me know if this does not help.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, September 15, 2009 8:12 AM

You can use google to search for other answers

Custom Search

More Threads

• Vertically Oriented Tab Pages
• Multicolumn tree/list view
• Viewing code generated by Windows Form Designer
• Finding dynamically created controls in Windows Form
• lasso selectable grid
• using generic custom controls that are in different assemblies
• codedom - execute functions
• how to set the custom scrollbars appearance like Autosroll .
• Deserializing Fields with custom CodeDomSerializer
• How to Show form in Quick lunch rather than Task bar