In the Windows Forms (.NET 3.5) application, it is often necessary to store and retrieve user -defined settings to easily access between different application instances. This article will discuss several available methods:
ConfigurationSettings
Although the configuration file (AppName.exe.config) can store settings, it is not suitable for saving the value back to the file. Therefore, this is not an ideal choice.
Registration table
The registry is another option for storage settings. However, the management registry is cumbersome and easy to make mistakes. Therefore, it is best to avoid the registry. Custom XML file
Create a custom XML file to save the configuration settings is a feasible method. However, there is a more direct and more convenient method.
The "Settings" tab of Visual Studio
Visual Studio provides a built -in mechanism to manage the application settings. Right -click the project in the solution resource manager, select "Properties", and then navigate to the "Settings" tab. Here, you can create and modify the application settings, which will be automatically stored in settings.Settings and settings.designer.settings files.
The method of accessing these settings in the code is as follows:
This method allows you to define settings with a specified scope (such as user or application) to make it suitable for reading and writing and reading only scenes.The above is the detailed content of What's the Best Way to Save Application Settings in Windows Forms Applications?. For more information, please follow other related articles on the PHP Chinese website!