如何获得控制台应用程序的路径
(1) 使用反射获得执行程序集路径
(2) 传递IO.Path.GetDirectoryName
示例代码:
static void GetAppPath()
{
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
Console.WriteLine(System.IO.Path.GetDirectoryName(path));
}
static void GetAppPath()
{
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
Console.WriteLine(System.IO.Path.GetDirectoryName(path));
}