I want to store the connection string and some parameters in app.config file which we generaly do for windows aplication but I can't find app.config file for console application. So how should I use this file, how to add this file or there is some other work arroud for the same functionality. I am working in console application
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Right click on application->Go to Add->you will see the exact picture What i have attached here->Pick the Application Config File.
Well, the other answers might have worked for others, but for me, adding a settings file to the project's properties solved the problem - it actually serialized the settings (which are editable via a visual designer) to the config file for me. So this way, the config file approach showed in the other answers here didn't work for me, but instead creating a settings file did work.
The steps are:
Project (not solution) > Add > New Item > Settings File
In addition, you might want to have your settings available in your code with strongly-typed values. I did the following:
So, now I could access my settings like this (from my console app):
After compilation, I found that these settings are stored automatically in a file named "AssemblyName.exe.config", alongside the console binary itself in the
Debug
directory.So, I think this is a cleaner, and more flexible way of creating and managing the app's config file.
NOTE: Am running Visual Studio Ultimate 2012, and am building a .NET 3.5 console app.
source: http://blog.nickgravelyn.com/2010/02/visual-studio-2010-xna-and-you/