|
-
Apr 5th, 2010, 02:17 PM
#1
Thread Starter
Hyperactive Member
My.Settings
I'm having trouble understanding how this works.Under my Project properties I select Settings and define the ones I need.Things like:
DefaultSaveToLocation (As String)
DefaultFileName (As String)
NoOfTimesAppStarted (As Integer)
and so on....
Under Form_Load I check to see if NoOfTimesAppStarted is 1.If so,display some configuration options,close the DialogBox and show Form1.Also,increase NoOfTimesAppStarted + 1.
Then My.Settings.Save().
This works,as the next time I start it,it skips the DialogBox and goes straigth to Form1.But under Settings,the value of NoOfTimesAppStarted is still 1.
Also,I can't seem to set the ApplicationPath.I use AppPath =My.Application.Info.DirectoryPath to get the path and save it to My.Settings.DefaultSaveToLocation,but no deal!
vb.net Code:
AppPath = My.Application.Info.DirectoryPath My.Settings.DefaultSaveToLocation = AppPath My.Settings.Save()
What am I doing wrong?
-
Apr 5th, 2010, 02:27 PM
#2
Re: My.Settings
you're not doing anything wrong per se... but when you look at it from the project settings, what you are seeing is the default settings... basically what is in the app.settings file in your project. At run-time though it will will first read in the yourapp.exe.config... then it will look for the user copy of the config file... and overlay the two, with the user settings file taking precidence over the app one. The merged result is what becomes your settings as you are trying to read it.
-tg
-
Apr 5th, 2010, 02:36 PM
#3
Thread Starter
Hyperactive Member
Re: My.Settings
I see what you mean.I just placed MessageBox.Show(My.Settings.DefaultSaveLocation) and it displayed it for me,although it doesn't appear under Settings.
Also,I read that it's good to use the PropertyGrid control to display the settings,but I can't find it anywhere?!
Last edited by BlackRiver; Apr 5th, 2010 at 02:40 PM.
-
Apr 5th, 2010, 03:26 PM
#4
Addicted Member
Re: My.Settings
Another question: where are these settings stored? I searched the registry, but I didn't find anything... and no file was created by the executable.
VBNetDude - Thinking Programmatically
By Silver Seal Software
Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most! 
-
Apr 5th, 2010, 03:41 PM
#5
Re: My.Settings
in the bin\Debug folder you should find a file with_your_app_name.exe.config ... that will hold the application scope settings & default values for user scoped settings. Then there is a user scoped config file that gets stored in your profile.
Some useful links:
http://www.vbforums.com/showthread.p...ettings+stored
http://www.vbforums.com/showthread.p...ettings+stored
http://msdn.microsoft.com/en-us/magazine/cc163812.aspx
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|