Settings.settings

D

David Gouge

Hi all,

A question on the verge of being OT, but here goes:

In my c# project in VS2005, I have a Properties folder in the Solution
Explorer and within that a Settings.settings file. At first glance i
decided this was a great place to store some simple configuration
settings for my app (like web proxy settings etc), but after putting the
settings in in VS2005 i cannot for the life of me find out a way of
getting the settings back out! The MSDN help seems to be contradictory
or incorrect and worryingly the closest info has been for vb.net only
(My.Settings).

So if anyone knows how to access this settings file in c# i would be
most grateful if you could let me know.

Best Wishes!

Dave
 
G

Glenn

David

VS2005 creates a CS file in the background. Instantiate it and then you
should be able to access the settings and properties.

HTH

Glenn
 
S

Stoitcho Goutsev \(100\) [C# MVP]

David,

You don't need to instantiate any class. The VS2005 generates everything for
you
just use

Properties.Settings.Default["MyPropertyName"];

where "MyPropertyName" is the name of the property.


HTH
Stoitcho Goutsev (100) [C# MVP]
 
D

David Gouge

Stoitcho said:
David,

You don't need to instantiate any class. The VS2005 generates everything for
you
just use

Properties.Settings.Default["MyPropertyName"];

where "MyPropertyName" is the name of the property.


HTH
Stoitcho Goutsev (100) [C# MVP]

David

VS2005 creates a CS file in the background. Instantiate it and then you
should be able to access the settings and properties.

HTH

Glenn

Thanks to both of you for the reply. Need to go off and find my hair
again. Now why couldn't they just include these useful bits of info in
some sort of 'help' file?

Cheers and have a good weekend!

Dave
 
G

Guest

Use an App.config file and place your settings in the <appSettings> section as
<add key="myKey" value="mystuff" />
Pete
 
D

David Gouge

Peter said:
Use an App.config file and place your settings in the <appSettings> section as
<add key="myKey" value="mystuff" />
Pete

Thanks for the reply Pete, but that doesn't really answer my question
and subsequently raises another question along the same lines about how
to then get the params out of the app.config file.

Cheers anyway and have a good weekend.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top