Resolved Fix 7zip.dll integration in C#

SiamIT

Active member
Joined
Aug 3, 2021
Messages
40
Programming Experience
5-10
i was trying/finding for a solution that i can use unzip/extract 7zip file natively in c#..

till now i was trying 7zdec.exe (console) application that i can invoke using process command. but it's not that user friendly as i need to track the progress properly on front end (my app/form/window)

so, after some digging (research) i found following nice link/reference that use 7z.dll inside c# to extract (extract only) 7z file and can monitor the progress (only files level)..

Initial Version

so, i have tried a bit.. but on testing i found a big issue.. it can only extract 1st file, if i try with next/2nd file.. it fails..

CLI Params For The Demo:
SevenZip e {ArchiveName} {FileNumber}

Sample That works!:
SevenZip e "c:\test.7z" 0

Sample That Fails:
SevenZip e "c:\test.7z" 1

and i even try to download/test the latest/last updated version from developer site:

Updated Version

But that has the same issue as well..

so, can any one please check the source and debug/fix it, as i have tried my level best but failed

thanks in advance

best regards
 
When it fails, what do does the program show on the console?

Since you have the source code, why can't you just build and step through the code of that "SevenZip.exe" and find out what's happening?
 
Is the README out of date for SharpCompress? It to me it reads like it doesn't support 7zip (but it does support LZMA which 7zip uses).
 
That attached project decompressed a 7zip file that I made, and it hs a "SevenZip" namespace, but also it doesn't seem to have any async methods so it might be lagging behind modern times/dev has a long todo list..

I just searched nuget for 7zip and installed something that looked fully managed and reasonably popular.. The only bit that wasn't intuitive was there wasn't an "extract all" method on the archive class, despite there being events that fire when extraction starts and ends*. instead one hs to enumerate the entries and extract each one; there's a "to directory" method that takes a modifier to replicate the file system within the zip, during extraction. Before I realized that I was doing a bit of a janky directory.create(path.getdirectoryname) on the "key" property of the zip entry

*( if you have to manually extract each file then the event seems moot cos you know when you start and end)
 
Last edited:
@Skydiver , i do apologize for not being able to get back to you earlier.. I got way too busy and thus forgot to check this thread. And of course better late than never. I am in debit with you and @cjard , because you to guys do you best on every question i do post.

@cjard , please read above message as well, that is for you too. And yes after testing few new option, i decided to go with following project (github) which is smaller and better. Though yes i had to update the project sources a bit to fill my needs:

C#:
https://github.com/adoconnection/SevenZipExtractor

1. adding preserve time stamp support when extract all files which was missing

2. adding extra progress monitoring as it there is other task that took long if the archive files has too many files/folders (i tried with a 7z file which has almost 20k files in it)

thanks again, for all your support.. (both of you)[/code]
 
Back
Top Bottom