In programming world everything is not a piece of cake. At times you need to do things more than available out-of-the-box. One of the common thing you seems to do is to modify or access your application’s configuration.
There are two type of configuration files:
-
App.Config (Used by Windows Project type application)
-
Web.Config (Used by Web Project type application)
We do lots of dirty stuffs to get the path and name of the file that is main configuration for the windows or web application.
The simplest way to access the configuration file associated with the currently running application is using:
System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
Verified against: Windows Forms, Console Application, WPF Application, ASP.NET MVC 3 application.