How to Obtain the Current Application Directory in C#
From time to time you may need to access a file within the current application directory .Net provides a property that is set to the absolute path to the application executable, and a method can be used to extract the folder name.
using System.IO; using System.Windows.Forms; string appPath = Path.GetDirectoryName(Application.ExecutablePath);
Console Application project types will have to manually add a reference to the
System.Windows.Forms assembly for the Application object to be exposed.
Last updated on: Friday 23rd June 2017