How to save IFormFile to disk?
<p>I'm trying to save a file on disk using <a href="https://weblogs.asp.net/imranbaloch/file-upload-in-aspnet5-mvc6" rel="noreferrer">this piece of code</a>. </p>

<pre><code>IHostingEnvironment _hostingEnvironment;
public ProfileController(IHostingEnvironment hostingEnvironment)
{
   _hostingEnvironment = hostingEnvironment;
}

[HttpPost]
public async Task&lt;IActionResult&gt; Upload(IList&lt;IFormFile&gt; files)
{
    foreach (var file in files)
    {
        var fileName = ContentDispositionHeaderValue
            .Parse(file.ContentDisposition)
            .FileName
            .Trim('"');

        var filePath = _hostingEnvironment.WebRootPath + "\\wwwroot\\" + fileName;
        await file.SaveAsAsync(filePath);
    }
    return View();
}
</code></pre>

<p>I was able to replace <strong>IApplicationEnvironment</strong> with <strong>IHostingEnvironment</strong>, and <strong>ApplicationBasePath</strong> with <strong>WebRootPath</strong>.</p>

<p>It seems like <strong>IFormFile</strong> doesn't have <strong>SaveAsAsync()</strong> anymore. How do I save file to disk then?</p>