App.config and saving the configurations...?

Hello,

I've searched the internet but couldn't find what i need.I created a config file:
App.config:
< xml version="1.0" encoding="utf-8" >
<configuration>
<appSettings >
<add key="Refresh" value="60" />
<add key="File" value ="einstein.jpg"/>
</appSettings>
</configuration>


I created a winform to view and change the information.

I can show the config ,it's ok:
this.refreshTextBox.Text =System.Configuration.ConfigurationSettings.AppSettings["Refresh"];
this.fileTextBox.Text = System.Configuration.ConfigurationSettings.AppSettings["File"];

I tried this code to save the changes but it doesn't work:
System.Configuration.ConfigurationSettings.AppSettings["Refresh"] =this.refreshTextBox.Text;
System.Configuration.ConfigurationSettings.AppSettings["Dosya"] = this.dosyaTextBox.Text;


What's the problem with that Isn't this possible to save

Thanks



Answer this question

App.config and saving the configurations...?

  • borba777

    Hi,

    Since App.Config values are read only, workaround for this problem would be Set and Get values to CurrentDomain.

    System.AppDomain.CurrentDomain.SetData("Domain",

    System.Configuration.ConfigurationSettings.AppSettings["Domain"];);

    label1.Text = System.AppDomain.CurrentDomain.GetData("Domain").ToString();

    Hope this would help you.

    Cheers,

    Kris



  • stephan mantler

    In .NET 2 you can write to an App.config file.

    Have a look at ms-ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/M_System_Configuration_Configuration_Save_1_63c16463.htm there is an example that should help you do what you want.


  • ctimko

    The file named App.config can't be written, read it please.


  • Debojyoti

    Try http://msdn2.microsoft.com/en-us/library/ms134088.aspx for the online version.

    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/M_System_Configuration_Configuration_Save_1_63c16463.htm is the help file.

  • gotelin

    ms-ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/M_System_Configuration_Configuration_Save_1_63c16463.htm

    I can't find this place. Can you tell me how



  • just.a.nerd

    Thank you.

  • App.config and saving the configurations...?