Solved

save properties setting at runtime

Posted on 2009-07-09
1
510 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now