This project is read-only.

VB.Net SevenZipSharp Progress

Nov 4, 2010 at 5:17 PM

Hello all!

I am using VB.Net 2010 and I would like to display the progress while I am extracting a 7zip archive.  So far, I have the below code, which will extract the file, but does not show any progress.

Dim zdllov As String = Application.StartupPath() & "\7z.dll"
ext As SevenZipExtractor = New SevenZipExtractor("C:\test-archive.7z")

I see that there are some delegates for file extraction, but I cannot for the life of me figure out how to actually implement them.  Can anyone help me, please?


Below is some of the things I have found, for reference.


Public Sub ExtractFileEvents(ByVal sender As Object, ByVal e As SevenZip.ProgressEventArgs) Handles sze.Extracting
If e.Cancel = True Then
MsgBox("Cancel event raised")
e.Cancel = WasCanceled
End If
End Sub


You absolutely don't have to use any lambda. Consider this alternative C# code:

[your method]
tmp.FileCompressionStarted += new EventHandler<FileInfoEventArgs>(tmp_FileCompressionStarted);

[method outside yours]
static void tmp_FileCompressionStarted(object sender, FileInfoEventArgs e)
        //place event code here

Nov 4, 2010 at 9:46 PM

Actually, after some stumbling, I think I found it -


Before I start to extract the archive, I can call VB.Net's AddHandler:

' Set library path

' Create extractor and specify the archive to extract
Dim ext As SevenZipExtractor = New SevenZipExtractor(archiveLocation)

' Handlers
AddHandler ext.Extracting, AddressOf ext_Extracting

 Start the extraction

And then I have the function that gets called:

    Public Sub ext_Extracting(ByVal sender As Object, ByVal e As SevenZip.ProgressEventArgs)
        Debug.WriteLine("Percent extracted: " & e.PercentDone)
    End Sub


Hopefully, someone else will find this useful as well. :-)

Dec 30, 2010 at 11:00 PM
Edited Dec 31, 2010 at 12:16 AM

Could you tell me what you have done for not having the following bug: Can not load 7-zip library or internal COM error! Message: failed to load library.
for now I blocked the above
Here is an part of my code in 2010 :
Imports SevenZip

sub extract(destindl as string)
If File.Exists(Application.StartupPath & "\7z.dll") = True Then
                SevenZipExtractor.SetLibraryPath(Application.StartupPath & "\7z.dll")
                Principal.voirinfo("Not Found 7z.dll")

                 exit sub
            End If
Dim ext As SevenZipExtractor = New SevenZipExtractor(destindl) 'here error

end sub
excuse me for my bad english and thanks you for your help

my answer is my project for x86 and my version I used was of 7z.dll x64 



Dec 31, 2010 at 8:44 PM

Unless I missed something, it sounds like you are trying to use a 64-bit version of 7z.dll, which will only work on a 64-bit OS, in a 64-bit project.  If your project is 32-bit (x86), you must use the 32-bit DLL file.