How do I access the Properties namespace from within a console app?

25,851

Solution 1

By default there is no Settings file in a Console application. However, you can add one simply by right-clicking your project in the solution explorer, choosing "Properties" and then in the resulting window, click the "Settings" tab.

There should be a link saying "Click here to create a default settings file". Once that's created, you're off to the races.

Solution 2

  1. Ensure the namespace of the class you're using is the default namespace of your project.

2.then you cna use

string s = Properties.Settings.Default.THENAMEINSETTINGS;

.

enter image description here

Share:
25,851
Nick
Author by

Nick

Software developer in the Boise, Idaho area. Interests: C#, C\C++, Objective-C Client-side scripting Design architecture, Patterns

Updated on July 05, 2020

Comments

  • Nick
    Nick almost 4 years

    I am trying to store/retrieve a value that is stored in the Application Settings. From within my console application I can not seem to access the Properties.Setting namespace. My web surfing has revealed that a little more work might be needed to do this from within a Console application. How does one do this?

    string test = Properties.Settings.Default.MyString;
    

    Thanks!

  • Nick
    Nick almost 15 years
    The settings tab doesn't a "Click here to create a default settings file" link. But I can "View Code" which takes me to a settings.cs file. There are some event handlers that need to be wired up. Does anyone know of a good example of hoe this is done?
  • barneymc
    barneymc about 10 years
    MyProjectName.Settings1.Default.DatabaseConnectionString should give you access to the Settings file.
  • Lydon
    Lydon almost 6 years
    That's a dead link
  • Thomas Adrian
    Thomas Adrian over 2 years
    in VS2022 the settingsfile is now a resource file