如何在ASP.NET核心中获取绝对路径Server.MapPath
的替代方法
我尝试过使用IHostingEnvironment
,但是它没有给出正确的结果。
IHostingEnvironment env = new HostingEnvironment();
var str1 = env.ContentRootPath; // Null
var str2 = env.WebRootPath; // Null, both doesn't give any result
我在wwwroot文件夹中有一个图像文件(Sample.PNG),我需要获取这个绝对路径。
https://stackoverflow.com/questions/43992261
复制相似问题