Can't get the root folder in some zip file. #415

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

Originally created by @kyuranger on GitHub (Sep 27, 2020).

Here is the sample of the zip file:
https://1drv.ms/u/s!AtcqjirAlaGYi4gSHBFiyRiNpU3sVg?e=d7NX60

And here is my code:
var archive = ZipArchive.Open(filename);
archive.Entries.ToList().ForEach(X =>
{
Debug.WriteLine(X.Key);
});

It will output all the file and folder except the root folder below:
k-sample-dl-h3101/

What's wrong with this? Is it a bug? Thank you.

Originally created by @kyuranger on GitHub (Sep 27, 2020). Here is the sample of the zip file: https://1drv.ms/u/s!AtcqjirAlaGYi4gSHBFiyRiNpU3sVg?e=d7NX60 And here is my code: var archive = ZipArchive.Open(filename); archive.Entries.ToList().ForEach(X => { Debug.WriteLine(X.Key); }); It will output all the file and folder except the root folder below: k-sample-dl-h3101/ What's wrong with this? Is it a bug? Thank you.
claunia added the questionnot bug labels 2026-01-29 22:11:34 +00:00
Author
Owner

@Deilan commented on GitHub (Oct 9, 2020):

Having the same issue here. Dupe of https://github.com/adamhathcock/sharpcompress/issues/267

@Deilan commented on GitHub (Oct 9, 2020): Having the same issue here. Dupe of https://github.com/adamhathcock/sharpcompress/issues/267
Author
Owner

@kyuranger commented on GitHub (Oct 12, 2020):

Having the same issue here. Dupe of #267

It seems it is the same problem. But while it doesn't be fixed since 2017.

Now I have to check whether the root folder missing every time.

@kyuranger commented on GitHub (Oct 12, 2020): > Having the same issue here. Dupe of #267 It seems it is the same problem. But while it doesn't be fixed since 2017. Now I have to check whether the root folder missing every time.
Author
Owner

@kyuranger commented on GitHub (Oct 12, 2020):

And also, I am not sure whether this problem only occurs in the root folder or may occur in any other folder.

@kyuranger commented on GitHub (Oct 12, 2020): And also, I am not sure whether this problem only occurs in the root folder or may occur in any other folder.
Author
Owner

@adamhathcock commented on GitHub (Oct 19, 2020):

#267 does not have the "root" folder as a key in the archive. SharpCompress won't add extra keys when reading or writing. That's a higher level concern.

I haven't looked at your file but I imagine it's the same issue. There just isn't the entry in the archive that you expect.

@adamhathcock commented on GitHub (Oct 19, 2020): #267 does not have the "root" folder as a key in the archive. SharpCompress won't add extra keys when reading or writing. That's a higher level concern. I haven't looked at your file but I imagine it's the same issue. There just isn't the entry in the archive that you expect.
Author
Owner

@Deilan commented on GitHub (Oct 19, 2020):

@adamhathcock Thanks for the explanation.

Is there a proposed workaround for that?

@Deilan commented on GitHub (Oct 19, 2020): @adamhathcock Thanks for the explanation. Is there a proposed workaround for that?
Author
Owner

@adamhathcock commented on GitHub (Oct 20, 2020):

Workaround for what? A key that isn't in the archive?

I don't know what you're trying to do other than something you expect is missing. Handle the missing key with your code.

If you're saying SharpCompress is making an archive without a key you expect then it's because the creating code wasn't told to make the key.

There is no zip standard about how folder keys should be handled. They're not even required. The only reason there are folder keys is because someone wanted empty folders to be handled in zip archives I imagine. I personally ignore them.

@adamhathcock commented on GitHub (Oct 20, 2020): Workaround for what? A key that isn't in the archive? I don't know what you're trying to do other than something you expect is missing. Handle the missing key with your code. If you're saying SharpCompress is making an archive without a key you expect then it's because the creating code wasn't told to make the key. There is no zip standard about how folder keys should be handled. They're not even required. The only reason there are folder keys is because someone wanted empty folders to be handled in zip archives I imagine. I personally ignore them.
Author
Owner

@kyuranger commented on GitHub (Oct 20, 2020):

OK, thanks a lot.

@kyuranger commented on GitHub (Oct 20, 2020): OK, thanks a lot.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#415