How do I read a local file in my ASP.NET Core project?

后端 未结 2 1677
孤街浪徒
孤街浪徒 2021-01-20 14:36

If I want to read a local file from my project, given a relative path from the project directory, how could I achieve this?

2条回答
  •  甜味超标
    2021-01-20 15:12

    Now that .NET Core has RTM-ed, you need to use IHostingEnvironment instead. It exposes WebRootPathand ContentRootPath.

提交回复
热议问题