January 9, 2016
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.
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); } } }