1 AppContext.BaseDirectory; 

结果为:....\ApplicationName\bin\Debug\net5.0\

2、获取文件目录

 1  using Microsoft.Extensions.Hosting;
 2  
 3  private readonly IHostEnvironment _hostEnvironment;
 4  
 5  public TestController(IHostEnvironment hostEnvironment)
 6  {
 7      _hostEnvironment = hostEnvironment;
 8  }
 9    
10  public IActionResult Test()
11  {
13   return Content(_hostEnvironment.ContentRootPath);
14  }

结果为:

结果为:....\ApplicationName

相关文章:

  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-09-26
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案