排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

使用IWebHostEnvironment对象即可
public readonly IWebHostEnvironment _webHostEnvironment; public ResourceController(IWebHostEnvironment webHostEnvironment) { _webHostEnvironment = webHostEnvironment; }
使用的时候:
//获取项目的根目录 string rootpath = _webHostEnvironment.ContentRootPath; //获取存储静态资源的wwwroot所在的根目录 string webRootPath = _webHostEnvironment.WebRootPath;
这个是3.x的,如果是2.x的可以参考:http://www.tnblog.net/aojiancc2/article/details/2347
还可以使用Directory.GetCurrentDirectory()获取项目根目录
合并路径可以这样使用
string baseDir = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads/files");
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价