There are a few ways in which we can get the current directory of the application using C#.
All of the below are running for a console application created using .NET 6 and returns the current directory the application is running under.
Get Current Directory Using Assembly Location
Console.WriteLine(System.IO.Path.GetDirectoryName(typeof(Program).Assembly.Location)); // Result: C:\Users\SAMEER\source\repos\ConsoleApp3\ConsoleApp3\bin\Debug\net6.0
Get Current Directory Using Current Domain Base Directory
Console.WriteLine(System.AppDomain.CurrentDomain.BaseDirectory); // Result: C:\Users\SAMEER\source\repos\ConsoleApp3\ConsoleApp3\bin\Debug\net6.0\
Get Current Directory Using Current Directory
Console.WriteLine(System.Environment.CurrentDirectory); // Result: C:\Users\SAMEER\source\repos\ConsoleApp3\ConsoleApp3\bin\Debug\net6.0
Get Current Directory Using GetCurrentDirectory
Console.WriteLine(System.IO.Directory.GetCurrentDirectory()); // Result: C:\Users\SAMEER\source\repos\ConsoleApp3\ConsoleApp3\bin\Debug\net6.0