C# Get Current Directory of Executable
You may want to know the current directory of the executable from where you can start
setup of an application configuration by browsing the current directory of an application.
Code:
using System;
using System.IO;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string path = Directory.GetCurrentDirectory();
Console.WriteLine(path);
Console.ReadKey();
}
}
}
Output:
d:\demo\ConsoleApplication\ConsoleApplication\bin\Debug
Description:
Directory class found at System.IO namespace .net base class library.
It provides various static methods which can be used for Creating, moving of the directories and subdirectories.
Exceptions: Don’t forget to handle an exceptions while working with directory manipulation.
The application may don’t have privileges to brows the directory.