Nicolas Dorier
Nicolas Dorier

Reputation: 7465

Where are user-mode .NET settings stored?

I'm wondering what is the magic behind .settings files in .NET. Imagine you create an assembly called in this example SettingsHolder, you create your settings class which is public with a string inside in user mode , then you compile.

Now you reference your assembly in MyApp, you compile then you can change the value in your application of your setting with the settings class generated in SettingsHolder and persist them.

Now go in the output directory of MyApp and there is no trace of your setting (nothing in the application configuration file, nothing in the assembly, nothing !).

What is going on?! (I have tried to source step debug in .NET source, and reflector to see what is happening, .NET seems to use LocalFileSettingsProvider (but it seems weird to me because there is nothing in MyApp.exe.config in the output directory).

Upvotes: 38

Views: 22087

Answers (4)

S Nash
S Nash

Reputation: 2499

In windows 11:(Assuming Windows is installed on drive C:)

C:\Users\YourUserName\AppData\Local\YourApplicationName\

There there is a another folder which contains a version folder and finally inside that user.config file. All settings are inside this file.

Upvotes: 0

MrCalvin
MrCalvin

Reputation: 1825

On OS >= Vista I will claim the the user-setting file it's located here:

%LOCALAPPDATA%\ yourcompany \ app-name \ ..\user.config

Upvotes: 1

ine
ine

Reputation: 14084

The setting files are stored in a different place for each user. To find them, click the start menu, click run, and paste:

%USERPROFILE%\Local Settings\Application Data\

and press enter. There will be a folder with your "Company Name" (whatever it is set to in your assembly) and then some more subfolders. The settings are stored in user.config.

Full path:

%USERPROFILE%\Local Settings\Application Data\<Company Name>\
<appdomainname>_<eid>_<hash>\<verison>\user.config.

In Windows Vista and newer, these are stored under:

%USERPROFILE%\AppData\Local\

More info:

Upvotes: 58

Andrew Hare
Andrew Hare

Reputation: 351486

The settings file is contained inside the compiled assembly.

Edit:

Just to clarify a bit. The code to get and set the settings from the file are compiled into the assembly. The values themselves are moved into Program.exe.config where Program is the name of your application. Reflector will let you see the code that gets and sets the value including the hard-coded key to the config file. The config file itself will show you the value and allow you to change it after the application has been built.

Upvotes: -4

Related Questions