A disk error occurred during a write operation. (Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))

假如想象 提交于 2019-12-01 21:23:14

问题


I am using EPPlus to read .csv file in vb.net. When I run this code, I get the error "A disk error occurred during a write operation.

(Exception from HRESULT: 0x8003001D (STG_E_WRITEFAULT))"

Here is my code :

Public Function ImportExcelSheet(ByVal filePath As String) As DataTable
    Dim dtImportData As New DataTable()
    Try
        'If csv file have header then "true" else "false"
        Dim hasHeader As Boolean = True
        Using pck = New OfficeOpenXml.ExcelPackage()
            Using stream = File.OpenRead(filePath)
                pck.Load(stream)
            End Using

What should I do to fix this error?


回答1:


I had the same error with a plugin I had created to import from excel. Originally I had saved the import file as .xls.

I opened this excel spreadsheet and resaved as .xlsx.

This solved the problem.

So maybe it is the file format that the csv was saved as.




回答2:


I get the same error reading xls file. It turns out the workbook had hidden rows on the first sheet. I inspected the document and removed the hidden rows and it worked perfectly



来源:https://stackoverflow.com/questions/30861419/a-disk-error-occurred-during-a-write-operation-exception-from-hresult-0x80030

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!