Mech_Engineer Mech_Engineer - 2 months ago 46
Vb.net Question

Extract file using SevenZip

I'm trying to add a file unzipper to my application, so I googled a little and stumbled on the sevenzipsharp library that is able to extract the most common archive formats.

So I for testing I created a simple application with a windows form.

Form screenshot

So the entered data is the file location

C:\Users\jeee\Desktop\CriticalSubPrintout.rar
and the extract location
C:\Users\jeee\Desktop\Test Extract


I added some code, without any documentation.. not my strong side apparently..

Imports SevenZip

Public Class Archiver

Private Sub btnExtractArchive_Click(sender As Object, e As EventArgs) Handles btnExtractArchive.Click

Dim Extractor As New SevenZipExtractor(tbExtractFile.Text)
Extractor.ExtractArchive(tbExtractPath.Text)

End Sub

End Class


This causes an error when I try and run the code

Error Image

Can anyone provide a sample code, or a link to a good example how-to-use
SevenZipSharp
? Because I searched and can't find any
VB.NET
samples.

Or maybe just help me figure out what I need to do.

Thanks.

Answer

You need to call SevenZipBase.SetLibraryPath with the path to 7z.dll, and make sure that you are using the correct version for your application (32- or 64-bit). e.g.

SevenZipBase.SetLibraryPath("C:\Dev\7z.dll")
Dim Extractor As New SevenZipExtractor(tbExtractFile.Text)
Extractor.ExtractArchive(tbExtractPath.Text)
Comments