SevenZipSharp
SevenZipSharp copied to clipboard
Can't get filenames while reading an archive
I'm using the following code to obtain a list of archive entries through SevenZipExtractor in a UWP app:
foreach (ArchiveFileInfo entry in szFile.ArchiveFileData) { Debug.WriteLine(entry.FileName); }
All I get is a bunch of "[no name]" and not the filenames. I'm using 7z.dll version 19.00. Other SvenZipSharp forks are working fine but they look kinda abandoned and not updated. Am I missing anything?
I don't see any reason that code shouldn't work, I even added unit tests showing it working with the example archives I've got. The only thing I can point to is that there's something particular in how the archive was created, but since you say other forks can retrieve the data I'm not sure what to suggest.
Are you able to provide the archive in question?
Sure, I will send you a link to download it (it's about 14 MB). For what is worth, Tlaster's fork of your repo is the one that allows me to get the filenames.
It's a little odd, as they've not done many changes - but I'll gladly debug it with your archive and see what I can find.
A brief update: I cloned your repo and wrote a small console application (NET 5.0). After I set the lib path, your code correctly list filenames. I'm starting to think that it's something not working with UWP apps. I'll dig it furher on my side.
It's a little odd, as they've not done many changes - but I'll gladly debug it with your archive and see what I can find.
They've changed something in library handling that makes SevenZipSharp works with UWP apps. I tried to adapt their changes to your code but I'm still getting a "library not found" error (which is not true because the DLL is at the right location).
EDIT: I'm sure now: your code is not working when used in a UWP app but works wonderfully in other cases (like the sample console app I wrote). It's not archive-related, then. Tlaster has found a way to make your code work in UWP app but it was last updated on Sept. 2020, so it is lacking newer code. It would be nice to join his edits just for UWP.
I'll dig into it a bit, but I don't really work with UWP myself.
So do you get any errors (library not found?), or is the only thing you notice in your UWP app that there's no filenames listed in your archive? The changes they've made are pretty destructive (just comment out code and skip methods), so I need to understand a bit more of what's happening before I can fix it myself.
Ok, here are my findings. If I clone your repo and reference it in a sample UWP app, I got LOTS of exceptions stating that DLL can't be found. That's not true because the DLL path is correct and the library is the right one, but this happen - I think - because in UWP you can't handle files directly because of sandboxing (e.g. you can't rely on instructions like "if (File.Exists(libPath))...": this will raise an exception for sure. On the other side, if I install your NuGet package, I don't get exceptions but I can't get archived file properties. While Tlaster's NuGet package can get to the file names, just like your code, it can't get some essential file properties. Both packages, in fact, can't tell if an archive entry is a Directory or is Encrypted (response is always false) but Tlaster's package successfully retrieves filenames. Probably he just needed this and didn't care about other features. I'm ready to help to make SevenSharpZip fully compatible with UWP platform (which is also the base for UNO platform).