Configuration file save directory with User C#scope

Asked

Viewed 119 times

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 of user 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.

  • 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 the Settings for that reason.

1 answer

1


  • 1

    I was looking for a cool article just like @LINQ (about why it’s this particular directory). I ended up making a custom file to manage the settings I need.

  • Nice, I also usually choose to make my own if I have time. Btw, does the answer answer answer your question or do you need more details? @Tuxpilgrim

  • Opa, was forgetfulness, marked as response, the article meets yes what wanted :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.