My.Settings files

B

Bob Altman

I've spent I-don't-know-how-long digging throught the documentation trying
to find an answer to what should be a pretty common question: If I persist
user settings via My.Settings, the settings get saved in a file in a folder
with a funky name. I can't find any documentation that tells me how that
name is constructed or what causes it to change.

I'm concerned that I will make some change to my program and, when I deploy
it to users, they will lose their user settings because the My.Settings
magic will suddenly start looking in a different folder.

Can someone point me at the relevant documentation for this subject? Thanks
a million!

- Bob
 
S

ShaneO

Bob said:
I've spent I-don't-know-how-long digging throught the documentation trying
to find an answer to what should be a pretty common question: If I persist
user settings via My.Settings, the settings get saved in a file in a folder
with a funky name. I can't find any documentation that tells me how that
name is constructed or what causes it to change.

I'm concerned that I will make some change to my program and, when I deploy
it to users, they will lose their user settings because the My.Settings
magic will suddenly start looking in a different folder.

Can someone point me at the relevant documentation for this subject? Thanks
a million!

- Bob
You might like to have a look at -

http://msdn2.microsoft.com/en-us/library/ms379611(VS.80).aspx

About a third of the way down an explanation is supplied on how the
"funky name" is derived.

You're correct regarding your fears of Settings being lost when your app
is upgraded, however, good 'ol Microsoft have even provided an answer
for that. Simply use "My.Settings.Upgrade". (But it should only be used
once!).

I do the following in any code where I use My.Settings -

1. I add a User-Scoped Boolean entry called "SettingsValid" and set its
default value to FALSE.

2. I add this code to the beginning of my Form Load event -
If Not My.Settings.SettingsValid Then
My.Settings.Upgrade()
My.Settings.SettingsValid = True
My.Settings.Save()
End If


Hope this helps.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
L

Linda Liu [MSFT]

Hi Bob,

Here's a good blog article about Application Settings which may be helpful:

'Client Settings FAQ'
http://blogs.msdn.com/rprabhu/articles/433979.aspx

As for upgrade user scoped settings, you could call the
ApplicationSettingsBase.Upgrade method first to retrieve the user scoped
settings value from the more recent installation of the application, and
then call the ApplicationSettingsBase.Save method to save the value to the
current version user.config file.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bob Altman

Thank you Linda and ShaneO, that's exactly what I was looking for!

Hey Linda, how do I throw a brick at the MSDN Library folks to ask them to
make it easier to find this stuff in the on-line docs? I've never run
across this magic Upgrade method, either in the docs or in magaizine
articles I've read. Seems like a pretty basic thing to want to do...

- Bob
 
L

Linda Liu [MSFT]

Hi Bob,

Thank you for your feedback!

You may visit the line "http://connect.microsoft.com" to submit a feedback
on MSDN library.

If you have any question about Dev in the future, you could use our Managed
Newsgroup Support Service and we will offer help to you in time.

Have a nice day!

Sincerely,
Linda Liu
Microsoft Online Community Support
 
B

Bob Altman

Linda Liu said:
If you have any question about Dev in the future, you could use our
Managed
Newsgroup Support Service and we will offer help to you in time.

Ok, I'm confused. I thought that this is a "managed newsgroup". I signed
up with MS managed newsgroups many years ago. I'm pretty sure I've gotten
emails from you in the past if I don't respond to postings in a reasonable
period of time confirming that I like the solution offerred. Is there
something else I need to do to participate in "managed newsgroups"?
 
L

Linda Liu [MSFT]

Hi Bob,

I'm sorry making you confused. I may not express clearly.

Yes, this is a managed newsgroup.

By "If you have any question about Dev in the future, you could use our
Managed Newsgroup Support Service and we will offer help to you in time.",
I mean if you have any question in the future, you could post your
questions in the newsgroup and we will help you in time.

Have a nice day!

Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top