Reputation: 441
I'm working for the first time with the built-in usersettings for a winforms appllication in c#. During the work I am confronted with the following problem.
In my development environment, everything works as expected, but as soon as I try to change the default settings on another machine, the following exception is thrown:
System.Configuration.ConfigurationErrorsException: Failed to save settings: An error occurred loading a configuration file: Could not find a part of the path 'C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0\tpqztu3w.tmp'. (C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0\user.config) ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Could not find a part of the path 'C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0\tpqztu3w.tmp'. (C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0\user.config) ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0\tpqztu3w.tmp'.
I try to save the Settings as follows:
Settings.Default.TheSettingsKey = Value;
Settings.Default.Save();
Is it required to have some special rights to be able to save user settings? Or am I missing something else?
Thanks for your help.
EDIT I've just found out, that the folder where the user settings should be stored is not existing (C:\Users\user\AppData\Local\Microsoft\App.exe_Url_ouhyykeidfbgy4o2rhziaurj2zdqs5x4\1.0.0.0). For my understanding it should be created when the settings are changed. Do I have to, or can I, force the creation of this folder?
Upvotes: 0
Views: 858
Reputation: 78
Properties.Settings.Default["SomeProperty"] = "Some Value";
Properties.Settings.Default.Save();
Upvotes: 0