The user.config file is not created, but is there app.config?

My program has some settings in which everyone has user coverage. However, when the program starts, it creates the AppName.exe.config file containing the settings.

When saving settings later at run time, it creates a user.config file (which did not exist previously) in AppData / Local / AppName / location, but this file contains only the saved setting.

Why is this happening? Why doesn't he create user.config or use this at startup if it exists?

+7
source share
1 answer

From Application Parameter Architecture on MSDN :

  • Application area settings can be saved in machine.config or app.exe.config files. Machine.config is always read-only, while app.exe.config is limited by security considerations for reading only for most applications.

  • User settings can be saved in the app.exe.config files, in which case they are considered as static default values.

  • Non-default user settings are stored in the new user.config file, where the user is the username currently running the application. You can specify a default value for the user area with the DefaultSettingValueAttribute parameter. Because user settings often change at runtime, user.config is always read / write.

What you see first is what you called, your "built-in settings", which are stored as (which Microsoft calls), the "static default" user reach parameters, which are saved in app.exe (as per 2).

And then, when you write down your settings at runtime, they are considered as โ€œnon-standardโ€ user coverage parameters, and they are written to user.config (according to 3), so why only then do you see the user.config file.

In short, there is no need for a user.config file for each user if the user parameters with the same value (default) for all.

+3
source

All Articles