0

I have to read app setting file and get some value from another my application. My settings class is located in a separated asembly, but when I try to get value: var id = MyAppSettings.Default.UserId

I get default value which is equal 0. I understood that setting file is 'exe' specific. Setting file is stored in
%USERPROFILE%\Local Settings\Application Data\<Company Name>\<appdomainname>_<eid>_<hash>\<version>\user.config

I tried to get path and have found this SO answer. But this code also return 0(my default value), because it looks config file in the local folder.

How to properly read setting file (not app.config and local)?

Community
  • 1
  • 1
user348173
  • 8,818
  • 18
  • 66
  • 102

1 Answers1

0

You can use this, if user.config file is accessible to your user and you have permission to read this file ::

 string path=@"%USERPROFILE%\Local Settings\Application Data\<Company Name>\<appdomainname>_<eid>_<hash>\<version>\user.config"
        System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(path);
        //and then access setting and so on....