我有一个由 MVC 项目(启动 UI)和几个类库项目组成的 Web 应用程序
请考虑这种情况.. Logistics.sln 包含
Proj1 - Logistics.UI (MVC)
Content
Images
Views
Controllers
web.config
Proj2 - Logistics.Domain (class library)
Proj3 - Logistics.Data (class library)
Proj4 - Logistics.Services (class library)
SomeRandomClass.cs
somefile.txt
Logistics.Services 项目有一个名为 SomeRandomClass 的类。如何在该类的方法中访问 somefile.txt?
尝试使用 HostingEnvironment.MapPath 但它指向 Logistics.UI 项目。
然后尝试了以下,但这也指向 UI 项目文件夹路径
var appDomain = System.AppDomain.CurrentDomain;
var basePath = appDomain.RelativeSearchPath ?? appDomain.BaseDirectory;