Question : Find number of entries in the commpressed file #281

Closed
opened 2026-01-29 22:09:28 +00:00 by claunia · 2 comments
Owner

Originally created by @trDiablo on GitHub (Mar 4, 2018).

Hello,

Is it possible to know the number of entry in a Zip file without reading and count all entrie ?

Currently i use

int nb = 0;
while (reader.MoveToNextEntry())
{
   if (!reader.Entry.IsDirectory) nb++;
}

but i have a performance issue about 3 or 4 second to a Zip file of 98Mb with 52 entries in it.
I probably missed a documentation but I did not find how to do.

Thx for your help

Originally created by @trDiablo on GitHub (Mar 4, 2018). Hello, Is it possible to know the number of entry in a Zip file without reading and count all entrie ? Currently i use ``` int nb = 0; while (reader.MoveToNextEntry()) { if (!reader.Entry.IsDirectory) nb++; } ``` but i have a performance issue about 3 or 4 second to a Zip file of 98Mb with 52 entries in it. I probably missed a documentation but I did not find how to do. Thx for your help
Author
Owner

@xupefei commented on GitHub (Mar 4, 2018):

Use ArchiveFactory whenever possible. It a lot faster than ReaderFactory.

I say "whenever" because there are some formats which ArchiveFactory does not handle well. For example, for a.tar.gz, ArchiveFactory returns only single file, which is a.gz. By contrast, ReaderFactory enumerates all files inside.

@xupefei commented on GitHub (Mar 4, 2018): Use `ArchiveFactory` whenever possible. It a lot faster than `ReaderFactory`. I say "whenever" because there are some formats which `ArchiveFactory` does not handle well. For example, for `a.tar.gz`, `ArchiveFactory` returns only single file, which is `a.gz`. By contrast, `ReaderFactory` enumerates all files inside.
Author
Owner

@trDiablo commented on GitHub (Mar 4, 2018):

Thx i have now the entry easily :)

For perfomances issues, i have same time with ReaderFactory or ArchiveFactory, decoding the whole file take 5 or 6 secondes (98 Mo, for 52 jpg entry).

I check my code to find if, and how, I can defer loading.

Thx

@trDiablo commented on GitHub (Mar 4, 2018): Thx i have now the entry easily :) For perfomances issues, i have same time with ReaderFactory or ArchiveFactory, decoding the whole file take 5 or 6 secondes (98 Mo, for 52 jpg entry). I check my code to find if, and how, I can defer loading. Thx
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#281