4
Regarding the configuration files in the C#, I’ve always used the App.config
only to record strings connection and some read-only variables, but currently I needed to modify some data at runtime, hence the question of scope: User
and Application
.
Scope of Application
Read-only and can be changed only in time design or by modifying the file [AssemblyName].exe.config
between application sessions.
User Scope
read and/or write at runtime and its values can be changed and saved in the code.
The question is this, when executing the Properties.Settings.Default.Save();
for a scope configuration file User
it is possible to change the location where the file with the persisted data will be saved?
In the Debug application is saving in
C:\Users\A_tuxpilgrim\AppData\Local\Nome_do_Projeto\Nome_do_Projeto.vshost._...\1.0.0\user.config
Obs: That one article and that question in Soen helped a lot, just missed the issue of the same directory.
If I’m not mistaken
Settings
ofuser
are always stored in that file, there’s no way to change the location because that’s the idea: save the information to a user location. But why not create your own config file? Then you get a lot more flexibility, you can encrypt the information, define the structure, etc.– João Martins
Thanks for the tip @Joãomartins! As I did not see a way to change this issue of the directory I will use a
xml
"". I think for my case it is better to have more flexibility even, I was just seeing the possibility of using theSettings
for that reason.– Tuxpilgrim