How to get admin privileges for editing app.config in C#?

后端 未结 3 591
一向
一向 2021-01-16 11:14

I\'ve got a program which uses app.config for storing some preferences. The problem is that if the program is installed in C:\\program files\\ t

3条回答
  •  一生所求
    2021-01-16 12:10

    Global app.config files (for EXEs) generally aren't meant to be edited by the program that uses them - more typically by installers and the like. What you probably want is simply User Settings (a simple matter of changing the scope). They generally get stored in AppData, and even better, proxy properties for the settings are auto-generated, so you can do something like:

    Properties.Settings.Default.Foo = "bar";
    Properties.Settings.Default.Save();
    

    This is (pretty much) all I've ever needed to do when managing settings!

提交回复
热议问题