mihooper1

I would like to change one of my system timer values in my code (I am allowing the user to change the polling rate, which is determined by this timer value). I would like to store this value in app.config so that each time the application starts the new value is applied to the timer. However, I am having trouble understanding how to access, modify, and save a new value in app.config.

Here is my app.config file:

< xml version="1.0" >

<configuration>

<appSettings>

<!-- User application and configured property settings go here.-->

<!-- Example: <add key="settingName" value="settingValue"/> -->

<add key="timer1.Enabled" value="True"/>

<add key="timer1.Interval" value="500"/>

</appSettings>

<startup>

</startup></configuration>

I would like to allow the user to vary the timer1.Interval value in my code, and then save this new value in app.config. Can anyone give me some suggestions on the correct way to do this So far I have written the following:

NameValueCollection appSettings =ConfigurationManager.AppSettings;

..but I am not sure how to modify the value of timer1.Interval. Any suggestions would be appreciated.



Re: .NET Base Class Library How do I change system timer value in app.config

Vivek Ragunathan

Hi

If you are using VS 2005 then you can try using the Settings feature if you like.

You can get more information from http://msdn2.microsoft.com/en-us/library/8eyb2ct1.aspx or http://msdn2.microsoft.com/en-us/library/aa730869(VS.80).aspx

Hope that helps.

Regards





Re: .NET Base Class Library How do I change system timer value in app.config

mihooper1

Perfect! Thanks for the help!