0

I want to save settings between two sessions.

I change the value, save it, close the program and its still the old one... WHY?

int test = Properties.Settings.Default.mode;
        System.Console.WriteLine(test);
        Properties.Settings.Default.mode = 1;
        Properties.Settings.Default.Save();
        test = Properties.Settings.Default.mode;
        System.Console.WriteLine(test);

XML:

<userSettings>
    <PyControl.Properties.Settings>
        <setting name="mode" serializeAs="String">
            <value>0</value>
        </setting>
    </PyControl.Properties.Settings>
</userSettings>
Daniel Bucher
  • 25
  • 1
  • 6

1 Answers1

0

Probably you were finding the settings file in wrong place? It isn't in your bin folder.

Your application will have a settings folder under %userprofile%\appdata\local or %userprofile%\Local Settings\Application Data depending on which version of Windows you're running, for settings that are user specific. If you store settings for all users, then they'll be in the corresponding folder under C:\users or C:\Documents and Settings for all user profiles (ex: C:\users\public\appdata\local).

Ref: Where are the Properties.Settings.Default stored?

Edit:

Assume if you're NOT using Windows IoT, try ~/.config/{AppName}/user.config? I don't write C# on RPi but above link mentioned this folder. -- If not here, I'm sorry that I can't offer further help :(

Tide Gu
  • 815
  • 1
  • 7
  • 21
  • User settings don't get saved in that `Program.exe.config` file, though - the user doesn't ordinarily have permission to write to that file. They get saved in a similarly named file somewhere the user has permission to write to (per the linked question). – Charles Mager Jun 07 '17 at 13:41
  • @DanielBucher Assume if you're NOT using Windows IoT, try `~/.config/{AppName}/user.config`? – Tide Gu Jun 07 '17 at 14:07
  • The Folder with my Application is not present in the .config folder – Daniel Bucher Jun 12 '17 at 08:10