In an ASP.NET MVC Core (.netcore2) application, I'm using the following method to read an Excel file.
[HttpPost]
public IActionResult Import (IFormFile importFile)
{
using (var excel = new ExcelPackage(importFile.OpenReadStream())
{
var sheet = excel.Workbook.Worksheets.FirstOrDefault();
if (sheet == null) return BadRequest("No worksheet.");
var events = /* import logic */
return Json(events);
}
}
However, epplus is throwing this exception:
COMException: A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))
I've used methods like this in the past to import Excel files, and I don't know what's going wrong.
I've checked:
- Versions of references on the project
- Excel file validity (I'm positive it's a valid xlsx file, not an old xls or other format)