asp.net 获取网站根目录某个文件

var path = HttpContext.Current.Server.MapPath("~/XmlConfig/myconfig.json");

 .net core获取网站根目录某个文件,不过IHostingEnvironment需要在构造函数中注入后才能使用。


IHostingEnvironment _hostingEnvironment;
var path = _hostingEnvironment.ContentRootPath + "//XmlConfig//myconfig.json";

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案