How to add Properties.Settings.Default in c#

6.1k Views Asked by At

I am not able to write "Properties.Settings.Default". It is not coming in the dropdown list. Is there any namespace that we can add?

5

There are 5 best solutions below

2
On BEST ANSWER

Add your project namespace to the Properties namespace. The default namespace defined in the project settings.

For instance if your project default namespace is MyApp.

MyApp.Properties.Settings.Default
0
On

Make sure you are on the same namespace and try to access the properties like this :

namespace.Properties.Settings.Default

or if you are on different namespace don't forget to use

using namespace
0
On

An additional hint on top of the above answers:

Go to solution explorer -> Properties folder -> Settings.settings -> Settings.Designer.cs file

and see which namespace is being used there. Ensure that you are using this namespace in your code file as others have suggested

0
On

Once you setup your environment in the settings under properties of the app. You want to reference it to the project like this:

using App.Properties.Settings

Then in the code you write you can use as example:

userName.Settings.Default

In this case userName is set within the settings.

0
On
  1. Set your Setting in your project go to Project => property => go to setting

  2. Set your element (string,int, ecc...)

  3. Save from program all values

Properties.Settings.Default.User = txtUser.Text; Properties.Settings.Default.Password = txtPass.Text; Properties.Settings.Default.Save();

if you use Windows 10, this is the directory of setting Values: C:\Users\AppData\Local<ProjectName.exe_Url_somedata>\1.0.0.0<filename.config>