Search code examples
c#app-configapplication-settings

Settings value saved during run time is not changing from design in visual studio


At my settings file i have a parameter "Is_Running" and it value is set as 0

at run time i will check the value like below

if(Settings.Default.Is_Running == 0)
{
Settings.Default.Is_Running = 1;
Settings.Default.Save();
upload_file();
Settings.Default.Is_Running = 0;
Settings.Default.Save();
}

Due to some reason i stopped the program in the middle of execution. Now the condition is always failing. So i checked value of Is_Running using a message box and it shows "1". I checked the app config file and it shows below

<setting name="Is_Running" serializeAs="String">
                <value>0</value>
            </setting>

Any idea why it still use "1"?


Solution

  • In VS you change the default values of settings. Real settings are stored in the path C:\Users\<UserName>\AppData\Local\<CompanyName>\<AppName>\<v‌​ersion>\user.config (for applications).

    Added by @Sachu.
    Since my application is windows service installed in server level, the path is little different. What I done is searched for user.config then got the file and path. Changed the value to 0 and it worked fine.

    In my case the path is:

    C:\Windows\SysWOW64\config\systemprofile\AppData\Local\<application_folder_name>
    \<application_name>\<version>\user.config