how to save IFormFile to disk Edit

Murugan Andezuthu Dharmaratnam | 26 February 2021 | 2387

In asp .net mvc you could save System.Web.HttpPostedFile to a disk using HttpPostedFile's method SaveAs("filename.ext"). Check the code below on how to save IFormFile to disk.


IFormFileCollection files = HttpContext.Request.Form.Files;
IFormFile file = files[0];
using (Stream fileStream = new FileStream(Path.Combine(sPath   modifiedFileName), FileMode.Create))