dotnet core 获取当前目录的方式
浏览(2382).NET获取目录的方式 | Windows | Linux | |||||
Console.WriteLine($"{Environment.CurrentDirectory}"); | E:\Projects\LinuxPathTest\LinuxPathTest\bin\Release\netcoreapp3.1\publish | /home/用户名/Desktop/Test | |||||
Console.WriteLine($"{Directory.GetCurrentDirectory()}"); | E:\Projects\LinuxPathTest\LinuxPathTest\bin\Release\netcoreapp3.1\publish | /home/用户名/Desktop/Test | |||||
Console.WriteLine($"{(new object()).GetType().Assembly.Location}"); | C:\Users\用户名\AppData\Local\Temp\.net\LinuxPathTest\3c0ont0d.sts\System.Private.CoreLib.dll | /var/tmp/.net/LinuxPathTest/5kkarywl.a5s/System.Private.CoreLib.dll | |||||
Console.WriteLine($"{Process.GetCurrentProcess().MainModule.FileName}"); | E:\Projects\LinuxPathTest\LinuxPathTest\bin\Release\netcoreapp3.1\publish\LinuxPathTest.exe | /home/用户名/Desktop/Test/LinuxPathTest | |||||
Console.WriteLine($"{AppDomain.CurrentDomain.BaseDirectory}"); | C:\Users\用户名\AppData\Local\Temp\.net\LinuxPathTest\3c0ont0d.sts\ | /var/tmp/.net/LinuxPathTest/5kkarywl.a5s/ | |||||
Console.WriteLine($"{AppDomain.CurrentDomain.SetupInformation.ApplicationBase}"); | C:\Users\用户名\AppData\Local\Temp\.net\LinuxPathTest\3c0ont0d.sts\ | /var/tmp/.net/LinuxPathTest/5kkarywl.a5s/ | |||||
标签: