EPPlus Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT)

1

How to access an Excel file using EPPlus? The code seems to be fine ..

   ViewBag.Message = "Cargar Almuerzos";
        byte[] file = System.IO.File.ReadAllBytes(@"C:\MENÚ DEL 09 AL 13 DE MAYO.xls");
        System.IO.MemoryStream ms = new System.IO.MemoryStream(file);
        using (ExcelPackage package = new ExcelPackage(ms))
        {
            if (package.Workbook.Worksheets.Count == 0)
            {
                string error = "Your Excel file does not contain any work sheets";
            }
        }
    
asked by chkeuchka 13.05.2016 в 14:43
source

2 answers

1

Because you pass a byte [] instead of directly assigning the file by FileInfo

FileInfo file = new FileInfo(@"C:\MENÚ DEL 09 AL 13 DE MAYO.xls");
using (ExcelPackage package = new ExcelPackage(file))
{
    if (package.Workbook.Worksheets.Count == 0)
    {
        string error = "Your Excel file does not contain any work sheets";
    }
}

Also try to assign an xls with no space or special characters such as the accent on the U, in the file name.

    
answered by 13.05.2016 в 19:29
0

I have the impression that the problem is in the spaces in the file name. Try changing the name or putting it in [].

    
answered by 13.05.2016 в 16:53