Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the data for Properties.Settings.Default saved?

Tags:

c#

wpf

settings

In my WPF application, I click on Settings.settings in the Solution Explorer and enter a StringCollection variable with a User scope:

alt text

in my app.config I see that they are saved there:

<userSettings>     <TestSettings.Properties.Settings>         <setting name="Paths" serializeAs="Xml">             <value>                 <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                     <string>one</string>                     <string>two</string>                     <string>three</string>                     <string>four</string>                     <string>five</string>                     <string>six</string>                     <string>seven</string>                 </ArrayOfString>             </value>         </setting>     </TestSettings.Properties.Settings> </userSettings> 

then I run my application and with this code:

StringCollection paths = Properties.Settings.Default.Paths;  Properties.Settings.Default.Paths.Add("added in code"); Properties.Settings.Default.Save();  foreach (var path in paths) {     System.Console.WriteLine(path); } 

which gives me this output:

one two three four five six seven added in code 

I run the application again and it gives me this output:

one two three four five six seven added in code added in code 

But I look at my app.config again and it still has the original values:

<userSettings>     <TestSettings.Properties.Settings>         <setting name="Paths" serializeAs="Xml">             <value>                 <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                     <string>one</string>                     <string>two</string>                     <string>three</string>                     <string>four</string>                     <string>five</string>                     <string>six</string>                     <string>seven</string>                 </ArrayOfString>             </value>         </setting>     </TestSettings.Properties.Settings> </userSettings> 

Where are the values that are added by the application being saved?

like image 284
Edward Tanguay Avatar asked Nov 26 '09 15:11

Edward Tanguay


People also ask

Where are properties settings default stored?

There is a folder called "Properties" under your project root folder, and there are *. settings file under that folder. That's where it gets stored.

Where are C# application settings saved?

User settings are saved in a file within a subfolder of the user's local hidden application data folder.

Where are .NET settings stored?

The settings are stored in user. config. Full path: %USERPROFILE%\Local Settings\Application Data\<Company Name>\ <appdomainname>_<eid>_<hash>\<verison>\user.

Where are WPF settings stored?

Under WPF settings are stored in Settings. These are usually in development mode in an editable file. You can also use the settings dynamically at runtime, such as adjustable user variables or app variables. Unlike UWP, you have to create, change and read the settings yourself.


2 Answers

Since you selected user scope, they are saved in each user profile directory, more specifically, inside the AppData folder of the user profile in a file named user.config.

The full path is dependent of the application.

In Windows 7 without roaming profile and with an Windows Forms Application named Example.Settings.CustomClass I'm getting the following folder:

C:\Users\[user]\AppData\Local\Microsoft\Example.Settings.CustomCl_Url_3qoqzcgn1lbyw2zx3oz1o3rsw2anyjsn\1.0.0.0 

Also note that they are saved taking in consideration the version of your application and that the values stored in App.config are the default values used for a new user.

like image 155
João Angelo Avatar answered Sep 21 '22 22:09

João Angelo


I was looking under Win 10 for the Settings. If anyone else need to know, they are not stored in Subfolder of Microsoft (see previous answer). Just look here:

C:\Users\[user]\AppData\Local\Example\Example...\1.0.0.0\ 
like image 34
Markus Avatar answered Sep 21 '22 22:09

Markus