Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys I have a App.Config file in my project that looks so :

XML
<configuration>
    <appsettings>
      <add key="DatabasePath" value="Database=C:\Users\Roelof\Documents\Visual Studio 2008\Projects\ClientServices <br mode=" hold=" />        \Database Information\Database\\CLIENTSERVICES.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost" />
      <add key="RegisteredHDD" value="No" />
      <add key="Activationcode" value="" />
    </appsettings>
</configuration>



The problem that I have is that at Runtime i change the fields. It changes but doesnt show in the file. Can anyone please help!

C#
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    config.AppSettings.Settings["RegisteredHDD"].Value = "Yes";
                    config.AppSettings.Settings["Activationcode"].Value = final;
                    config.AppSettings.Settings.Add("LastDateFeesChecked", DateTime.Now.ToShortDateString());

                    config.Save(ConfigurationSaveMode.Modified);
Posted
Updated 4-Jul-11 4:20am
v3

1 solution

When you say that it doesn't show in the file, are you sure that you are looking at the right file? I've recently answered another question caused by confusion as to what app.config really is. In your project, you'll see app.config, yet if you look in the build folders you won't see this file. Why is that?

Well, app.config is a placeholder configuration file which gets renamed to match your application executable. Suppose your exe is called MyApplication.exe, the config file that is read by the application is MyApplication.exe.config.

Check that file for your changes rather than app.config (and do it before you recompile the application, you don't want to overwrite your changes just because of a build).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900