Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 398
Nick Avatar asked May 11 '09 22:05

Nick


2 Answers

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.

like image 191
womp Avatar answered Oct 01 '22 20:10

womp


  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

like image 44
yu yang Jian Avatar answered Oct 01 '22 20:10

yu yang Jian