我在生产系统中有一个错误,当用户在软件中选择要上传的 excel (.xlsx) 文件时,应用程序会引发异常:Attempted to read past the end of the stream. - at ICSharpCode.SharpZipLib.Zip.ZipHelperStream.ReadLEShort()
我正在使用ExcelDataReader
SharpZipLib 更新到 0.65。有人有想法吗?
ExcelDataReader Extract Method that using SharpZipLib: Exception was throwed in zipFile = new ZipFile(filestream);
谢谢。
public bool Extract(Stream fileStream)
{
if (null == fileStream) return false;
CleanFromTemp();
NewTempPath();
_isValid = true;
ZipFile zipFile = null;
try
{
zipFile = new ZipFile(fileStream);
IEnumerator enumerator = zipFile.GetEnumerator();
while (enumerator.MoveNext())
{
ZipEntry entry = (ZipEntry)enumerator.Current;
ExtractZipEntry(zipFile, entry);
}
}
catch (Exception ex)
{
_isValid = false;
_exceptionMessage = ex.Message;
Log.Trace(string.Format("{0} - {1}",ex.Message ,ex.StackTrace), this.GetType());
CleanFromTemp();
}
finally
{
fileStream.Close();
if (null != zipFile) zipFile.Close();
}
return _isValid ? CheckFolderTree() : false;
}