简体   繁体   中英

Why doesn't the C# Properties.settings.default.key read the updated value after a Properties.Settings.Default.save()?

In the application (c# console app) settings file I have: Key = "", with scope as User.

I then have the following code:

Properties.Settings.Default.Key = "value1";
Properties.Settings.Default.Save();

string k = Properties.Settings.Default.Key; // here, k is an empty string.

What am I missing?

Is persisting the settings and accessing the settings code executed in same user context? Lets say if the persisting code executed with administrative privilege(Impersonate) then it may behave differently.

Your variable name "Key" is causing the problem, change the variable name from "Key" to another name then it should work.

Here is a step by step guide to save the config file: http://www.codeproject.com/Tips/350010/Saving-User-Settings-in-Winform-Application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM