471,317 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Equivalent of My.Settings in c#

GS
How do I use My.Settings equivalent in C#? Below is part of MSDN documentation about accessing settings file. I wrote C# console application using VS 2005 and .NET 2.0 and would like to use new settings file in 2.0 and can not find any documentation about using c#, there is some for VB.NET.



This section contains topics describing the My.Settings object and the tasks it enables you to accomplish.

My.Settings
The properties of the My.Settings object provide access to your application's settings. To add or remove settings, use the Project Designer. For more information, see How to: Add or Remove Application Settings.

The methods of the My.Settings object allow you to save the current user settings or revert the user settings to the last saved values.

Tasks
The following table lists examples showing how to access an application's forms.

To See
Update the value of a user setting
How to: Change User Settings in Visual Basic

Display application and user settings in a property grid
How to: Create Property Grids for User Settings in Visual Basic

Save updated user setting values
How to: Persist User Settings in Visual Basic

Determine the values of user settings
How to: Read Application Settings in Visual Basic


Dec 22 '05 #1
2 20452
GS wrote:
How do I use My.Settings equivalent in C#? Below is part of MSDN
documentation about accessing settings file. I wrote C# console
application using VS 2005 and .NET 2.0 and would like to use new
settings file in 2.0 and can not find any documentation about using c#,
there is some for VB.NET.


See http://msdn2.microsoft.com/en-us/library/25zf0ze8.aspx for info on
how to add/remove application settings. Once you have added the
settings file you can use the designer to add settings to the app. The
Settings class by default gets created in the Properties namespace under
your application. In code you can create an instance of the Settings
class and then access the settings within it as well as call its
methods. Ex:

Properties.Settings s = new Properties.Settings();
Console.WriteLine(s.UserSetting1);
s.UserSetting1 = "New Value";
s.Save();
--
Tom Porterfield
Dec 22 '05 #2
GS
Perfect. Thanks. That's what I was looking for.
What an improvement over .NET 1.1!
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
GS wrote:
How do I use My.Settings equivalent in C#? Below is part of MSDN
documentation about accessing settings file. I wrote C# console
application using VS 2005 and .NET 2.0 and would like to use new settings
file in 2.0 and can not find any documentation about using c#, there is
some for VB.NET.


See http://msdn2.microsoft.com/en-us/library/25zf0ze8.aspx for info on how
to add/remove application settings. Once you have added the settings file
you can use the designer to add settings to the app. The Settings class
by default gets created in the Properties namespace under your
application. In code you can create an instance of the Settings class and
then access the settings within it as well as call its methods. Ex:

Properties.Settings s = new Properties.Settings();
Console.WriteLine(s.UserSetting1);
s.UserSetting1 = "New Value";
s.Save();
--
Tom Porterfield

Dec 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Breck Carter | last post: by
6 posts views Thread by guy | last post: by
10 posts views Thread by Anthony | last post: by
10 posts views Thread by Bishoy | last post: by
5 posts views Thread by Andy | last post: by
27 posts views Thread by pamela fluente | last post: by
11 posts views Thread by Spam Catcher | last post: by
3 posts views Thread by prads | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.