Dotnet
获取当前目录
//获取模块的完整路径。
string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
//F:\Xiang\Code\UnitTest\ZBin.Web.UnitTest\bin\Debug\netcoreapp3.1\testhost.exe
//获取和设置当前目录(该进程从中启动的目录)的完全限定目录
string path2 = System.Environment.CurrentDirectory;
//F:\Xiang\Code\UnitTest\ZBin.Web.UnitTest\bin\Debug\netcoreapp3.1
//获取应用程序的当前工作目录
string path3 = System.IO.Directory.GetCurrentDirectory();
//F:\Xiang\Code\UnitTest\ZBin.Web.UnitTest\bin\Debug\netcoreapp3.1
//获取程序的基目录
string path4 = System.AppDomain.CurrentDomain.BaseDirectory;
//F:\Xiang\Code\UnitTest\ZBin.Web.UnitTest\bin\Debug\netcoreapp3.1\
//获取和设置包括该应用程序的目录的名称
string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//F:\Xiang\Code\UnitTest\ZBin.Web.UnitTest\bin\Debug\netcoreapp3.1\
string path6 = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
//file:///F:/Xiang/Code/UnitTest/ZBin.Web.UnitTest/bin/Debug/netcoreapp3.1/ZBin.Web.UnitTest.dll
//想要获得测试目录的,用这个
var path7 = Path.GetFullPath("..\\..\\..");
//F:/Xiang/Code/UnitTest/ZBin.Web.UnitTest