[英]DotNetZip doesn't read all entries from zip stored at azure blob storage
I have a zip stored in azure blob storage which I'm streaming it locally and iterating its entries.我有一个 zip 存储在 azure blob 存储中,我在本地流式传输它并迭代它的条目。
I'm getting the stream like that:我得到这样的 stream:
BlobClient blob = _blobServiceClientProp.GetBlobContainerClient(blobExtractionSource.ContainerName)
.GetBlobClient(blobExtractionSource.BlobName);
Stream zipStream = await blob.OpenReadAsync().ConfigureAwait(false);
The stream length is valid (8890655642 bytes). stream 长度有效(8890655642 字节)。
Using DotNetZip 1.16, I'm reading from the zip stream:使用 DotNetZip 1.16,我正在读取 zip stream:
ZipFile zipFile = ZipFile.Read(zipStream);
The problem is that I'm getting wrong number of entries.问题是我输入的条目数有误。 According to DotNetZip, I have 41082 entries in the zip which is wrong.根据 DotNetZip,我在 zip 中有 41082 个条目,这是错误的。 I checked the number of entries both by the Entries property (zipFile.Entries) and also by iterating and count them manually.我通过 Entries 属性 (zipFile.Entries) 以及手动迭代和计数来检查条目数。
If I switch to IO.Compression.ZipArchive
and iterating the zip entries, IO.Compression.ZipArchive
is telling me I have 85,413 entries in the zip, which is the right number of entries.如果我切换到IO.Compression.ZipArchive
并迭代 zip 条目, IO.Compression.ZipArchive
告诉我 zip 中有 85,413 个条目,这是正确的条目数。
Any suggestions how can I still work with DotNetZip and make it get the right number of entries?有什么建议我仍然可以使用 DotNetZip 并使其获得正确数量的条目吗?
Note that when reading from the same zip locally (after I manually download it) with same version of DotNetZip, I successfully get all the entries.请注意,当使用相同版本的 DotNetZip 在本地读取相同的 zip(在我手动下载后)时,我成功获取了所有条目。
Through ZipArchive we could able to pull off the exact number.通过 ZipArchive,我们可以得出准确的数字。 Below is the code that worked for us.下面是对我们有用的代码。
var stream = await blobClient.OpenReadAsync();
using ZipArchive zip = new ZipArchive(stream, ZipArchiveMode.Read);
Console.WriteLine(zip.Entries.Count);
Edit编辑
The Code that worked for us using DotNetZip使用 DotNetZip 为我们工作的代码
BlobClient blob = blobServiceClient.GetBlobContainerClient("container-1")
.GetBlobClient("samplezip1.zip");
Stream zipStream = await blob.OpenReadAsync().ConfigureAwait(false);
ZipFile zipFile = ZipFile.Read(zipStream);
Console.WriteLine(zipFile.Entries.Count);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.