mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Can't get the root folder in some zip file. #415
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@Deilan commented on GitHub (Oct 9, 2020):
Having the same issue here. Dupe of https://github.com/adamhathcock/sharpcompress/issues/267
@kyuranger commented on GitHub (Oct 12, 2020):
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):
And also, I am not sure whether this problem only occurs in the root folder or may occur in any other folder.
@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.
@Deilan commented on GitHub (Oct 19, 2020):
@adamhathcock Thanks for the explanation.
Is there a proposed workaround for that?
@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.
@kyuranger commented on GitHub (Oct 20, 2020):
OK, thanks a lot.