开发者

Is appname.exe.config required for user specific settings?

I'm building a simple winforms application which is using built-in settings for saving program options. All of the settings are per-user.

As I can see from the generated cs file the default settings are embedded in the source code but the application still reads the appname.exe.config file when launched. If I delete the file the application seems to be working fine but I want to make sure that it will not break anything.

So is the file required if I am only using per-u开发者_StackOverflow中文版ser settings?


You should be using user settings instead of a configuration file. Refer to this article for more information, including how to read/write user settings.


The settings designer embeds the default value in a [DefaultSettingValue] attribute. The following section in the Remarks section of the attribute is relevant:

Different settings providers may have different requirements or limitations on the use of the DefaultSettingValueAttribute. For example, the LocalFileSettingsProvider does not require this attribute, and will override any value provided by this attribute if there are any values—default or user-modified— already present in the data store.

LocalFileSettingsProvider is the default provider. So, it's there but it doesn't get used.


If you are using the Application Settings and you want persistence of the settings then yes this is where the options are saved. If you delete the file it will simply recreate it if the user changes a setting and you are setting the setting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜