Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

I was just wondering if there is a way to save just some specific settings for use between sessions.

Properties.Settings.Default.Save() saves everything but i need only a few settings saved and others empty at the start of next session.


i did it in order to use them as global variables throughout forms, i am aware there are better ways for this but still my question stands, is there actually a way to save just some settings?
Posted
Updated 9-Jul-12 10:32am
v2
Comments
OriginalGriff 9-Jul-12 15:18pm    
If you don't need them saved, why have you added settings for them? Settings are specifically for saving values for the next session...
lewax00 9-Jul-12 15:22pm    
Well now I feel like I copied your comment... :P
lewax00 9-Jul-12 15:18pm    
If you need them to reset each time then why have them be settings at all? Settings are intended to be the things that carry over between sessions.
OriginalGriff 9-Jul-12 15:51pm    
Great minds and all that! :laugh:
Maybe it'll make the OP realize it's true...

1 solution

You're missing the point. Is there a way? Maybe, but probably not, because they aren't meant to be used that way.

Sure, you could store the value in a temporary variable, set the value in the settings to empty, save, then return the temporary values to the settings. That would get the effect you want. But it's going to be harder to maintain, and it's just not the "right" way to do things.

What you should really do is store the ones that do not need to be saved in a static class or a singleton. Then all your forms get access to the same data, and your settings are actually settings. This is really the solution you should go for, it may not be exactly what you're asking for, but you will get the same result, and you don't have to try and find some loop hole in functionality to achieve it. Work with the language and framework, don't try to fight against it!
 
Share this answer
 
v2
Comments
metalclaw 9-Jul-12 18:00pm    
ok this answer i respect, it provided some insight. imma close this question now...
SoMad 9-Jul-12 18:06pm    
I agree, +5. It is better to do things like this the right way than to try to bend something into shape just because it is already there.

Soren Madsen

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