vb.net 写入操作期间发生磁盘错误。(来自 HRESULT 的异常:0x8003001D (STG_E_WRITEFAULT))

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30861419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:12:14  来源:igfitidea点击:

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

asp.netvb.netopencsv

提问by Margaretha

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.

我正在使用 EPPlus 在 vb.net 中读取 .csv 文件。运行此代码时,出现错误“写入操作期间发生磁盘错误。

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

(来自 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?

我应该怎么做才能修复这个错误?

回答by Cyborg

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

我创建的一个从 excel 导入的插件也遇到了同样的错误。最初我将导入文件保存为 .xls。

I opened this excel spreadsheet and resaved as .xlsx.

我打开这个 excel 电子表格并重新保存为 .xlsx。

This solved the problem.

这解决了问题。

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

所以也许这是 csv 保存为的文件格式。

回答by Raymond Anderson

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

我在读取 xls 文件时遇到相同的错误。原来工作簿在第一张纸上隐藏了行。我检查了文档并删除了隐藏的行,它运行良好