Solved

save properties setting at runtime

Posted on 2009-07-09
1
513 Views
Last Modified: 2012-05-07
Having trouble saving setting value. I created a Settings.settings file in my C# project and would like to save a variable to that file. I looked at the example at MSDN:

To Write and Persist User Settings at Run Time
Access the user setting and assign it a new value, as shown in the following example:
Properties.Settings.Default.myColor = Color.AliceBlue;

My code:
Properties.Settings.Default.apiCallsCalled = 1000;

I get an error saying '=' is an invalid token in class, struct, interface or member declaration. Can someone tell me what's wrong?

Thanks,
0
Comment
Question by:acclimate
1 Comment
 
LVL 10

Accepted Solution

by:
stormist earned 250 total points
ID: 24819482
Set it within your form load or init section. Also, do not forget to call the Save() method, your settings will not automatically persist.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question