ExtractToDirectory has missing files when working with encrypted zip files which contain directories #698

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

Originally created by @aaronbarak666-art on GitHub (Aug 19, 2025).

Created an encrypted zip file using 7zip with the following structure:

TestDirectory\a.txt
TestDirectory\b.txt

The following code only extracts a.txt:

using IArchive archive = ArchiveFactory.Open(zipPath, new ReaderOptions() { Password = "test" } );
archive.ExtractToDirectory(outputPath)

Zip files without a password, or without directories seem to work ok
Also 7z files work.

This seems to be an issue with ExtractAllEntries, since this test case works on version 0.38.0, when I use WriteToDirectory instead.
This does break again in 0.40.0, because of #900 which made WriteToDirectory use ExtractAllEntries

Originally created by @aaronbarak666-art on GitHub (Aug 19, 2025). Created an encrypted **zip** file using 7zip with the following structure: ``` TestDirectory\a.txt TestDirectory\b.txt ``` The following code only extracts `a.txt`: ``` using IArchive archive = ArchiveFactory.Open(zipPath, new ReaderOptions() { Password = "test" } ); archive.ExtractToDirectory(outputPath) ``` **Zip** files without a password, or without directories seem to work ok Also **7z** files work. This seems to be an issue with `ExtractAllEntries`, since this test case works on version `0.38.0`, when I use `WriteToDirectory` instead. This does break again in `0.40.0`, because of #900 which made `WriteToDirectory` use `ExtractAllEntries`
Author
Owner

@Morilli commented on GitHub (Aug 20, 2025):

Can't reproduce on either latest master or with version 0.40.0 using the same code and the following test archive: TestDirectory.zip

Does this only happen with specific zip files? Could you share an example file?

@Morilli commented on GitHub (Aug 20, 2025): Can't reproduce on either latest master or with version `0.40.0` using the same code and the following test archive: [TestDirectory.zip](https://github.com/user-attachments/files/21899941/TestDirectory.zip) Does this only happen with specific zip files? Could you share an example file?
Author
Owner

@aaronbarak666-art commented on GitHub (Aug 21, 2025):

I've tried your file and it did work.
I did manage to reproduce it again with very small text files (one character). Maybe it's connected to the compression method?
Small files are compressed in 7-zip as AES-256 Store instead of AES-256 Deflate
Here's an example for a non-working zip file
TestDirectory.zip

@aaronbarak666-art commented on GitHub (Aug 21, 2025): I've tried your file and it did work. I did manage to reproduce it again with very small text files (one character). Maybe it's connected to the compression method? Small files are compressed in 7-zip as `AES-256 Store` instead of `AES-256 Deflate` Here's an example for a non-working zip file [TestDirectory.zip](https://github.com/user-attachments/files/21914651/TestDirectory.zip)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#698