Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Equivalent of My.Settings in c#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GS - 22 Dec 2005 16:48 GMT
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
   
Tom Porterfield - 22 Dec 2005 17:17 GMT
> 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();
Signature

Tom Porterfield

GS - 22 Dec 2005 17:21 GMT
Perfect. Thanks. That's what I was looking for.
What an improvement over .NET 1.1!
>> How do I use My.Settings equivalent in C#? Below is part of MSDN
>> documentation about accessing settings file. I wrote C# console
[quoted text clipped - 13 lines]
> s.UserSetting1 = "New Value";
> s.Save();

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.