[Tutorial]Unzipping with VB.Net

Posts 1–15 of 15 · Page 1 of 1
[Tutorial]Unzipping with VB.Net
I'm going to explain you guys, how to unzip .rar/.zip/.7z and so on with visual basic.

We first off need the SharpZibLibrary, which can be found in attachments.

After downloading it SharpZipLib_0855_Bin.zip, unrar it. Now start a new vb project.



Now add the .dll to your project.

Solution-Explorer > Righ***1ck on your project > Add Reference > Browse > Select the .dll from the "net-20" folder.





Add the following namespace

Code:
Imports ICSharpCode.SharpZipLib
Make 1 Textbox and 2 Buttons.

Textbox1 = Path to the folder where the archive is in
Button1 = FolderBrowserDialog to browse the archive
Button2 = Unzipping the archive

Set the openfiledialog...

On button1_click event...

Code:
Dim fbd as folderbrowserdialog
fbd.showdialog
textbox1.text = fbd.selectedpath
On button2_click event...

Declare a fastzip

Code:
Dim unz as zip.fastzip()
Now to unzip something...

Code:
unzip.ExtractZip("ZipDirectory", "targetdirectory", "filefilter")

Let's say we want to save it to the desktop...

Code:
Dim desktop as string
on Form_Load

Code:
desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) ' getting desktop path of any computer
In our case it is...

Code:
unz.ExtractZip(Textbox1.text & "\Filename"", desktop & "\Foldername"", "")
To set the filename / Desktop directory you can do the following...

Code:
Dim directory As String = System.IO.Path.Combine(desktop, "Foldername to save it to")

            Dim file As String = System.IO.Path.Combine(textbox1.Text, "foldernametounzip.zip")
-> ->

Code:
unz.ExtractZip(file, directory, "")
This might be a bit confusing, I am currently confusing myself lul...here is how it should look like...

Code:
Imports ICSharpCode.SharpZipLib
Public Class Form1
    Dim desktop As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fbd As New FolderBrowserDialog
        fbd.ShowDialog()
        filepath.Text = fbd.SelectedPath
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try

            Dim directory As String = System.IO.Path.Combine(desktop, "Foldername to save it in")

            Dim file As String = System.IO.Path.Combine(filepath.Text, "FileToUnzip.zip")

            Dim unz As New Zip.FastZip()
            unz.ExtractZip(file, directory, "")

        Catch
            MsgBox(ErrorToString)
        End Try
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    End Sub
End Class

You sure can do a lot with the sharpzip library, not just unzipping. I hope you did understand me ^.-
SharpZipLib_0855_Bin.zipattachment deleted · 143 downloads before removal
Good job, easy to follow.
1+
Very Nice. Thanks for sharing
Looks good, thanks for sharing

Nice Sig Hej
this is good for updaters, since servers do not allow uploads of exes that can be downloaded...
nice release man,good tut!
i like the foreign language. -.-
Vb.net is universal
Nice Tutorial.

if i was still using Vb.net then this would have come in handy........
Quote Originally Posted by XGelite View Post
Nice Tutorial.

if i was still using Vb.net then this would have come in handy........
what are you using nao?
Quote Originally Posted by Blubb1337 View Post
what are you using nao?
C#.
way better for game.
VB is unfortunately really no good for that.
On what kind of game are you currently working on?

Any specific ideas yet? Concept :P?

(Just curious)
Quote Originally Posted by Blubb1337 View Post
On what kind of game are you currently working on?

Any specific ideas yet? Concept :P?

(Just curious)

Well thats what im trying to figure out. Its going to be 3rd person more than likely. Its going to be sort-of like Zelda. That style. i guess you could call it RPG.
Im still trying to come up with a storyline for it. I dont even have a name for it yet.
Thinking of doing a jungle + urban after an earthquake type of environment/setting. Going to be for pc and xbox. Dont expect any jaw dropping graphics and animation lol
wery nice relase my friend!!!! +1
Closed, Month Old Bump >.<
Posts 1–15 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us