Hi Jon,
I can't give you as much help as others on here but I can tell you how
I use the settings.
In my solution explorer, there is a Properties folder beneath the
project. Expanding that out allows me to see the Resources and the
Settings. When I have something that I want to persist, I double click
on the Settings item and it brings up an editor to allow me to enter
the variables and their scope (application or user). Once I have my
variables set up, I go back to my code where I want to use them.
At the top, I put the following using statement:
using myNamespace.Properties;
That keeps me from having to type so much when I want to use them.
Then, in my code, I use
Settings.Default.MySetting
I do this for keeping track of the window size and position and some
colors. Mostly settings that the user will change. To get them to
persist between application uses, you must make the change to the
setting and then do a Settings.Default.Save. I usually do this in the
Closing event of my primary form.
I'm not exactly sure where they are saved. I've not had many problems
out of them and haven't investigated that. I did a quick search in the
documenation and didn't see anything obvious. I ran FileMon and watched
as a small app came up and then went down. It appears that there are
some files being opened and closed in my accounts Local Settings folder
as well as the Application Data folder.
HTH some
On Nov 15, 10:08 am, "Jon Slaughter" <Jon_Slaugh...@Hotmail.com>
wrote:
I wrote an app that needed to save settings such as colors, fonts, etc...
after hours of trying to use ConfigurationManager and AppSettings along with
a few other things I finally found that I could just use
global::Properties.xxx.Settings.Default.yyy
where xxx is the namespace and yyy is a setting created in the settings
dialog.
This is an extremly easy way to save and restore properties but I'm
wondering how general it is and if its a good idea to use it?
Also, where are these settings stored? It seems that its somewhere in the
CLR(maybe not the appropriate term) cache or something? The only way I
could reset the settings is by setting them to some default values and then
saving them.
One issue I was having was when I was using AppSettings[key]. I could never
find any settings even though I had both application and user defined
settings created in app.config. Are these settings suppose to be the same
as the ones above or are they different? (such as a different section/group
name in the xml config file?)
e.g., if I created a user or application defined setting called
"SomeSetting" in the settings page and then tried to reference it by
AppSettings["SomeSetting"], I would also get a null string.
Thanks,
Jon