I read ZipInputStream from a stream. There are 10 ZipEntries, but size of all of them is -1! I can't figure out why, because there are data, so it must be > 0. Here's my code:
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);
...
}
And on the line var buffer = new byte[zipEntry.Size]
I've got an OverflowException. When I check zipEntry.Size
- it's always -1. If I write var buffer = new byte[4096]
for example it's ok, but not correct. Any thoughts, please? Thanks in advance!