Why would/should I use a ".settings" file instead of taking the information and storing it in a flat file? How do I access and modify the settings from this window from my application windows. Do I need to create an instance of the file or is it static?
views:
310answers:
2Why would/should I use a ".settings" file instead of taking the information and storing it in a flat file?
You can store it in a flat file. But, with C# in VS IDE there is a default support to store and access these settings
From MSDN:
....allows you to create and access values that are persisted between application execution sessions. These values are called settings. Settings can represent user preferences, or valuable information the application needs to use. For example, you might create a series of settings that store user preferences for the color scheme of an application. Or you might store the connection string that specifies a database that your application uses. Settings allow you to both persist information that is critical to the application outside of the code, and to create profiles that store the preferences of individual users.
How do I access and modify the settings from this window from my application windows. Do I need to create an instance of the file or is it static? How do I access and modify the settings from this window from my application windows.
Refer to these links: http://msdn.microsoft.com/en-us/library/aa730869%28VS.80%29.aspx http://www.jeffkwak.com/blog/archive/2008/02/29/winform-settings-with-c.aspx
In addition to PK's excellent answer, the settings are also strongly-typed. When you get/set settings within your code, they are already in the required type, so you don't have to worry about serialization - it's handled for you.