Search code examples
c#.netpropertiesglobal-variablesapplication-settings

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


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!


Solution

  • 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.