How to Get Application Path in C#/CSharp

To get application path in C#/CSharp, we make use of GetExecutingAssembly() static method of Assembly class, which resides in System.Reflection namespace.  Example is given below.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
using System;
using System.Reflection;
namespace Hello_World
{
class Program
{
static void Main(string[] args)
{
string path = Assembly.GetExecutingAssembly().Location;
Console.WriteLine(path);
}
}
}
using System; using System.Reflection; namespace Hello_World { class Program { static void Main(string[] args) { string path = Assembly.GetExecutingAssembly().Location; Console.WriteLine(path); } } }
using System;
using System.Reflection;

namespace Hello_World
{

    class Program
    {
        static void Main(string[] args)
        {
            string path = Assembly.GetExecutingAssembly().Location;
            Console.WriteLine(path);
        }
    }
}