1

I know that there is some questions about this already but none of them have helped me.

So I have a .NET c# application that have settings in its app.config like this :

  <userSettings>
    <MyApp.Client.Main.Properties.Settings>
      <setting name="LoginSwitchUserRestart" serializeAs="String">
        <value>False</value>
      </setting>
      <setting name="SkinName" serializeAs="String">
        <value>Blue</value>
      </setting>
    </MyApp.Client.Main.Properties.Settings>
  </userSettings>

This is supose the be saved in a file located here C:\Users\Me\AppData\Roaming\MyCompany_Healthcare_Systems_A\MyApp.vshost.exe_Url_fch0ekqas3qxil4p11igflywwa1klvng\5.8.0.0\user.config

acording to this code :

var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoaming);

MessageBox.Show(config.FilePath);

But there is no file? I also have several version of this application running both from within Visual Studio and outside as a release version but I can´t still find the setting file?

The operating system is Windows 10 64 bit.

Banshee
  • 15,376
  • 38
  • 128
  • 219
  • I hadnt thought of where to look - so I did a test, mine was under appdata\\appname.exe_\\user.config - Im wondering if this helps find it programattically (havent checked yet) http://stackoverflow.com/questions/793657/how-to-find-path-of-active-app-config-file – BugFinder Apr 14 '16 at 11:59
  • Under my appdata I only got roaming, local and locallow. And now when looking under local I can see my company folder and user.config!? – Banshee Apr 14 '16 at 12:04
  • sorry yes, it was under local.. so, the question is can we get it programattically according to http://stackoverflow.com/questions/621265/can-i-control-the-location-of-net-user-settings-to-avoid-losing-settings-on-app user.config will always be where I found it.. but guessing the hash isnt really doable. still looking – BugFinder Apr 14 '16 at 12:12

1 Answers1

0

You can do having added references for System.configuration and sticking it in uses with

ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath

this returns the path to user.config

BugFinder
  • 17,474
  • 4
  • 36
  • 51