If I want to read a local file from my project, given a relative path from the project directory, how could I achieve this?
You can get the ApplicationBasePath
from PlatformServices.ApplicationEnvironment
. This will make it possible to resolve non-absolute paths relative to your application base path.
Now that .NET Core has RTM-ed, you need to use IHostingEnvironment
instead. It exposes WebRootPath
and ContentRootPath
.