By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,939 Members | 1,541 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,939 IT Pros & Developers. It's quick & easy.

How to access default user settings ?

P: n/a
I developed a Win form with VS.NET 2005 + .NET 2.0 in C#
There are some application settings are "User" scope and stored in
xxx.settings,
I can access them via Settings class and changethem with Settings.Save();
However, if I change and save them then my app will read the change from
the user.config , my question is how to access the original default setting?
Jan 24 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
They are in the application.exe.config file, in the "userSettings" section.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

In case of Minimalism, break Philip Glass.

"RedHair" <re*****@u.s.awrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
>I developed a Win form with VS.NET 2005 + .NET 2.0 in C#
There are some application settings are "User" scope and stored in
xxx.settings,
I can access them via Settings class and changethem with Settings.Save();
However, if I change and save them then my app will read the change from
the user.config , my question is how to access the original default
setting?


Jan 24 '07 #2

P: n/a
Yes, I know.
Is there any class is able to access them directly?
"Kevin Spencer" <un**********@nothinks.comwrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
They are in the application.exe.config file, in the "userSettings"
section.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

In case of Minimalism, break Philip Glass.

"RedHair" <re*****@u.s.awrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
>>I developed a Win form with VS.NET 2005 + .NET 2.0 in C#
There are some application settings are "User" scope and stored in
xxx.settings,
I can access them via Settings class and changethem with Settings.Save();
However, if I change and save them then my app will read the change from
the user.config , my question is how to access the original default
setting?



Jan 24 '07 #3

P: n/a
No, there is nothing ready-made to do this. If you use the Visual Studio
Project Settings to create the Application Settings, what it does is to
create both a Configuration file and a class that inherits
System.Configuration.ApplicationSettingsBase. The class is used in an
application to retrieve values in the Application Configuration file.
Settings are defined as being Application-scoped or User-scoped via
attributes, as well as the default values for User Settings, with the
System.Configuration.DefaultSettingValueAttribute. So, since the default
values are not exposed as properties in the class, you would have 2 possible
ways to get at them:

1. Use reflection on the class to get the values of the attributes.
2. Write your own custom Application Settings class.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RedHair" <re*****@u.s.awrote in message
news:u8**************@TK2MSFTNGP02.phx.gbl...
Yes, I know.
Is there any class is able to access them directly?
"Kevin Spencer" <un**********@nothinks.comwrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
>They are in the application.exe.config file, in the "userSettings"
section.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

In case of Minimalism, break Philip Glass.

"RedHair" <re*****@u.s.awrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
>>>I developed a Win form with VS.NET 2005 + .NET 2.0 in C#
There are some application settings are "User" scope and stored in
xxx.settings,
I can access them via Settings class and changethem with
Settings.Save();
However, if I change and save them then my app will read the change from
the user.config , my question is how to access the original default
setting?




Jan 25 '07 #4

P: n/a
Thank you!
While creating the Settings.settings with VS.NET 2005, there is also a
app.config file?
I should add *.settins or *.config file to read/write application settings?

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:uz**************@TK2MSFTNGP06.phx.gbl...
No, there is nothing ready-made to do this. If you use the Visual Studio
Project Settings to create the Application Settings, what it does is to
create both a Configuration file and a class that inherits
System.Configuration.ApplicationSettingsBase. The class is used in an
application to retrieve values in the Application Configuration file.
Settings are defined as being Application-scoped or User-scoped via
attributes, as well as the default values for User Settings, with the
System.Configuration.DefaultSettingValueAttribute. So, since the default
values are not exposed as properties in the class, you would have 2
possible ways to get at them:

1. Use reflection on the class to get the values of the attributes.
2. Write your own custom Application Settings class.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"RedHair" <re*****@u.s.awrote in message
news:u8**************@TK2MSFTNGP02.phx.gbl...
>Yes, I know.
Is there any class is able to access them directly?
"Kevin Spencer" <un**********@nothinks.comwrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
>>They are in the application.exe.config file, in the "userSettings"
section.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

In case of Minimalism, break Philip Glass.

"RedHair" <re*****@u.s.awrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
I developed a Win form with VS.NET 2005 + .NET 2.0 in C#
There are some application settings are "User" scope and stored in
xxx.settings,
I can access them via Settings class and changethem with
Settings.Save();
However, if I change and save them then my app will read the change
from
the user.config , my question is how to access the original default
setting?




Jan 26 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.