Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up a configuration file for .NET console applications?

Is it possible to use a ".net configuration" file for a .NET console application?

I'm looking for an equivalent to web.config, but specifically for console applications...

I can certainly roll my own, but If I can use .NET's built in configuration reader then I would like to do that...I really just need to store a connection string...

Thanks

like image 269
mmattax Avatar asked Oct 03 '08 16:10

mmattax


2 Answers

Yes - use app.config.

Exactly the same syntax, options, etc. as web.config, but for console and WinForms applications.

To add one to your project, right-click the project in Solution Explorer, Add..., New Item... and pick "Application Configuration File" from the Templates box.

like image 146
Dylan Beattie Avatar answered Sep 19 '22 09:09

Dylan Beattie


app.config... If you have an App.config in your project, it will get copied as executableName.exe.config in the case of a console application.

like image 44
oglester Avatar answered Sep 20 '22 09:09

oglester