我从流中读取 ZipInputStream。有 10 个 ZipEntries,但它们的大小都是 -1!我不知道为什么,因为有数据,所以它必须> 0。这是我的代码:
var zipInputStream = new ZipInputStream(new MemoryStream(reports));
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.GetNextEntry()) != null)
{
var fileName = Path.GetFileName(zipEntry.Name);
if (String.IsNullOrEmpty(fileName)) continue;
var identifier = fileName.Split('.')[1];
var buffer = new byte[zipEntry.Size];
zipInputStream.Read(buffer, 0, buffer.Length);
var report = encoding.GetString(buffer);
...
}
就行var buffer = new byte[zipEntry.Size]
了,我有一个 OverflowException。当我检查时zipEntry.Size
-它总是-1。例如,如果我写var buffer = new byte[4096]
它没关系,但不正确。请问有什么想法吗?提前致谢!