0

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.

Mech_Engineer
  • 535
  • 1
  • 19
  • 46
  • Personally wouldn't use SevenZipSharp, maybe try this?: http://www.codeproject.com/Tips/257193/Easily-zip-unzip-files-using-Windows-Shell32 – Tom Pitts Sep 08 '16 at 12:11
  • Why? Please explain. And does the method in the link also support .RAR files? – Mech_Engineer Sep 08 '16 at 12:20
  • I've personally found SevenZipSharp a bit unreliable with documentation. Here is a previous question asking about .RAR files: http://stackoverflow.com/questions/18522605/unpack-a-rar-file – Tom Pitts Sep 08 '16 at 12:24

1 Answers1

1

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)
Mark
  • 8,140
  • 1
  • 14
  • 29