Different results with ZipArchive.Open() & ReaderFactory.Open() #395

Closed
opened 2026-01-29 22:11:13 +00:00 by claunia · 3 comments
Owner

Originally created by @Dem0n2die4 on GitHub (Apr 15, 2020).

Hello!
I have a strange situation. I use version 0.24.0.0
I try to read inner structure of zip archive. In first varian I manually check header of file and then move with:

IArchive archive;
archive = ZipArchive.open(stream);
using(archive)
{
    foreach (var entry in archive.Entries)
    {
    }
}

and it works fine.
After that I tried to rewrite it to ReaderFactory in due to support rar archives:

using(var reader = ReaderFactory.open(stream))
{
    while(reader.MoveToNextEntry())
    {
    }
}

in the result some files are missing.
Please tell me what I missed.
Thx for your time.

Originally created by @Dem0n2die4 on GitHub (Apr 15, 2020). Hello! I have a strange situation. I use version 0.24.0.0 I try to read inner structure of zip archive. In first varian I manually check header of file and then move with: ``` IArchive archive; archive = ZipArchive.open(stream); using(archive) { foreach (var entry in archive.Entries) { } } ``` and it works fine. After that I tried to rewrite it to ReaderFactory in due to support rar archives: ``` using(var reader = ReaderFactory.open(stream)) { while(reader.MoveToNextEntry()) { } } ``` in the result some files are missing. Please tell me what I missed. Thx for your time.
Author
Owner

@adamhathcock commented on GitHub (Apr 15, 2020):

You can use ArchiveFactory if you really want to open regardless of archive.

ReaderFactory reads entries a different way than Archive so there could be bugs or your zip isn't made for seekable reading. Use ArchiveFactory unless you really need the case of non-seekable streams.

@adamhathcock commented on GitHub (Apr 15, 2020): You can use ArchiveFactory if you really want to open regardless of archive. ReaderFactory reads entries a different way than Archive so there could be bugs or your zip isn't made for seekable reading. Use ArchiveFactory unless you really need the case of non-seekable streams.
Author
Owner

@Dem0n2die4 commented on GitHub (Apr 15, 2020):

You can use ArchiveFactory

Yep, thank you! Already found that way)
Can I ask you about seeking structure of rar5? I understand that this is a little bit off-topic.
Is it works fine? I tried code from and it works as good as need to.

@Dem0n2die4 commented on GitHub (Apr 15, 2020): > You can use ArchiveFactory Yep, thank you! Already found that way) Can I ask you about seeking structure of rar5? I understand that this is a little bit off-topic. Is it works fine? I tried code from and it works as good as need to.
Author
Owner

@adamhathcock commented on GitHub (Apr 15, 2020):

RAR is simple header then data. Zip is usually way more complicated. I keep some format documentation in the repo.

@adamhathcock commented on GitHub (Apr 15, 2020): RAR is simple header then data. Zip is usually way more complicated. I keep some format documentation in the repo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#395