📜  如何使用 ihostingenvironment 参数调用类 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:15.937000             🧑  作者: Mango

代码示例1
public class FileReader
{
    private readonly IHostingEnvironment env;
    public FileReader(IHostingEnvironment env)
    {
        if(env==null)
            throw new ArgumentNullException(nameof(env));

        this.env = env;
    }

    public string ReadFile(string fileName)
    {
       var filename = Path.Combine(env.WebRootPath, fileName);
    }
}