Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# VS2013 How to use App.config in a console application after publish it

I have a console application with an App.Config with some keys. The user that will use this app needs to change the values of some of the keys before run it.

If a publish my application I don't see the App.Config after install it. How can I add this functionality?

Thanks.

like image 678
aramos Avatar asked Jun 16 '17 14:06

aramos


2 Answers

When you publish the application the app.config is transformed into an exe.config. Open up that file and make your edits.

If you installed this program with a click once installer the easiest way to find the file is to just run the app, open the task manager (CTRL-SHIFT-ESC), select the app and right-click|Open file location. You should then find the *.exe.config file in the same folder.

like image 113
Swazimodo Avatar answered Sep 20 '22 01:09

Swazimodo


This should help for your understanding:

https://msdn.microsoft.com/en-us/library/ms228995.aspx

specifically: "In a Windows Forms applications (iterchangeable with console in this instance) not deployed using ClickOnce, an application's app.exe.config file is stored in the application directory, while the user.config file is stored in the user's Documents and Settings folder. In a ClickOnce application, app.exe.config lives in the application directory inside of the ClickOnce application cache, and user.config lives in the ClickOnce data directory for that application."

Short version to help: Look into one of these subfolders post deploy if you are using a clickonce publish option- C:\Users\UsersNameGosHere\AppData\Local\Apps\2.0

Outside of getting you up and running for the here and now, If you have specific user designated values that need mods after deployment then you should really look into putting them into user settings rather than app settings.

like image 33
Travis Acton Avatar answered Sep 22 '22 01:09

Travis Acton