59

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?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047

3 Answers3

60

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.

João Angelo
  • 56,552
  • 12
  • 145
  • 147
  • 1
    I am having the same problem. I see that its getting updated in AppData\Local\xxxx folder when I save. But when I launch the application its not getting read from there. How do I force it to read from there ? – coolshashi Mar 20 '15 at 02:45
  • @coolshashi, it is probably best for you to create a new question where you describe the exact conditions in which you're observing the failure to load the user settings. – João Angelo Mar 20 '15 at 08:55
  • 10
    This answer is still correct for Windows 10 and applies to WPF and winforms. So the path to `user.config` is `<...>\Users\\AppData\Local\\.exe_Url_<32 random characters>\`. Your application name was truncated at 25 characters which may be the maximum? – Kay Zed Jul 30 '16 at 16:10
  • If you want to obtain this path programmatically, [look here](http://stackoverflow.com/a/7069366/344541). That's `ConfigurationManager.OpenExeConfiguration(...).FilePath`. – Kay Zed Jul 30 '16 at 17:19
  • 2
    `<32 random characters>`... Hello from Microsoft! – Yousha Aleayoub Apr 18 '20 at 14:44
  • Those `<32 random characters>`, as elaborated [in parallel Q&A](https://stackoverflow.com/questions/2488277/net-application-settings-path), are related to the application' hash. – Dmitry Kravtsov Feb 24 '23 at 08:18
4

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\
Markus
  • 61
  • 2
1

I stumbled across an easy way to find the path(s).

  1. Open the Application Properties.
  2. Under the "Application" tab, select "Assembly Information...".
  3. Change the value of "Company". Select OK to save.
  4. Select the "Settings" application properties tab.
  5. Select "Synchronize" (first button in the options at the top of the tab).
    You should then receive a Visual Studio information dialogue saying "No user.config files were found in any of the following locations:" followed by a list of locations where the settings are saved.
Jason Snelders
  • 5,471
  • 4
  • 34
  • 40