C#中AppDomain.CurrentDomain.BaseDirectory及各种路径获取方法

string path = "";

//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。 结果:E:\项目\Test
path = Environment.CurrentDirectory;
// 获取程序的基目录。结果:E:\项目\Test\ path = System.AppDomain.CurrentDomain.BaseDirectory; // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 结果:E:\项目\Test path = System.Environment.CurrentDirectory ; // 获取应用程序的当前工作目录,注意工作目录是可以改变的,而不限定在程序所在目录。 结果:E:\项目\Test path = System.IO.Directory.GetCurrentDirectory(); // 获取和设置包括该应用程序的目录的名称。 结果:E:\项目\Test\ path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//获取项目下的Log文件路径 结果:E:\项目\Test\Log path
= System.Web.HttpContext.Current.Server.MapPath("~/Log");

 

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2021-12-16
  • 2021-06-15
  • 2021-12-19
  • 2021-08-03
  • 2021-08-26
猜你喜欢
  • 2021-07-05
相关资源
相似解决方案