Results 1 to 12 of 12

Thread: Download rar/zip file and extract to a certain folder

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Question Download rar/zip file and extract to a certain folder

    I need my app to download a rar/zip file and extract them to a certain folder when done downloading and extracting the file i need it to remove the rar/zip file it also needs a progress bar with the Percentage included

    heres all the code i have so far:

    Code:
    Imports System.Net
    Imports System.IO
    
    
    Public Class Form1
        Private Sub donatebutton_Click(sender As Object, e As EventArgs) Handles donatebutton.Click
            'Donate button
            Dim webAddress As String = "http://custom-zombies.com/Forums/index.php?action=treasury#MakeDonation"
            Process.Start(webAddress)
        End Sub
    
        Private Sub Treeview1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
            If e.Node.Text = ("Gcz Hut") Then
                'Start code
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Gcz_hut)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Gczhut)
                'End code
            ElseIf e.Node.Text = ("Radiation Xtreme (RADX)") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.RadX)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Radiation_Xtreme)
            ElseIf e.Node.Text = ("Rise") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.riseimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Rise1)
            ElseIf e.Node.Text = ("Prison Mission - v1.1 NEW") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.prison)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Prison_Mission)
            ElseIf e.Node.Text = ("Official GCZ Maps") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.bg_body)
                'tell user about the map...
                RichTextBox1.Text = ("Double Click to see all Official GCZ Maps")
            ElseIf e.Node.Text = ("Community Maps") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.bg_body)
                'tell user about the map...
                RichTextBox1.Text = ("Double Click to see all Community Maps")
            ElseIf e.Node.Text = ("Crash") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.crashimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Crashtxt)
            ElseIf e.Node.Text = ("Bunbury") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Bunbury)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Bunburytxt)
            ElseIf e.Node.Text = ("Bacon") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Baconimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Bacontxt)
            ElseIf e.Node.Text = ("[BZB] Untergrund 1.1.1") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.untergrund)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.untergrundtxt)
            ElseIf e.Node.Text = ("Son's of zombie anarchy") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.anarchyimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.anarchytxt)
            ElseIf e.Node.Text = ("Bitroom") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.bg_body)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.bitroomtxt)
            ElseIf e.Node.Text = ("Ambush") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Ambushimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Ambushtxt)
            ElseIf e.Node.Text = ("Nazi_Zombie_Bullfrog") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Bullfrogimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Bullfrogtxt)
            ElseIf e.Node.Text = ("Ill manor v3") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.bg_body)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Illmanorv3txt)
            ElseIf e.Node.Text = ("Imminent") Then
                'Note there is no extension on GCZ_team image.
                Me.PictureBox1.Image = (My.Resources.Imminentimg)
                'tell user about the map...
                RichTextBox1.Text = (My.Resources.Imminenttxt)
            End If
        End Sub
    
        Private Sub DownloadButton_Click(sender As Object, e As EventArgs) Handles DownloadButton.Click
            'Gcz Hut Download
            If TreeView1.SelectedNode.Text = ("Gcz Hut") Then
                My.Computer.Network.DownloadFile(
                "http://www.cohowinery.com/downloads/WineList.txt",
                "C:\Users\Greenlungs81\Desktop\test\1.txt")
                'Radiation Xtreme Download
            ElseIf TreeView1.SelectedNode.Text = ("Radiation Xtreme (RADX)") Then
                My.Computer.Network.DownloadFile(
                "http://www.cohowinery.com/downloads/WineList.txt",
                "C:\Users\Greenlungs81\Desktop\test\2.txt")
            End If
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            'Gcz Hut More Images
            If TreeView1.SelectedNode.Text = ("Gcz Hut") Then
                PictureBox1.ImageLocation = "http://4.bp.blogspot.com/_16A_bWvSzZ4/TPSNe8NuxyI/AAAAAAAACxQ/7LVUVgv3cA8/s1600/DogPoopILOVEU.img_assist_custom.jpg"
                'Radiation Xtreme More Images
            ElseIf TreeView1.SelectedNode.Text = ("Radiation Xtreme (RADX)") Then
                PictureBox1.ImageLocation = "http://4.bp.blogspot.com/_16A_bWvSzZ4/TPSNe8NuxyI/AAAAAAAACxQ/7LVUVgv3cA8/s1600/DogPoopILOVEU.img_assist_custom.jpg"
            End If
        End Sub
    End Class

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Download rar/zip file and extract to a certain folder

    With regards to showing progress, have you read the documentation for that DownloadFile method? Presumably not. You should do so now.

    As for decompression, the Framework can handle ZIP files but not RAR, so you'll require a third-party component. If you're using that for RAR then you may as well use it for ZIP too. Here's one that can handle both:

    http://sharpcompress.codeplex.com/

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Re: Download rar/zip file and extract to a certain folder

    i dont need them to be rar files but how would i add that to my code

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Download rar/zip file and extract to a certain folder

    Quote Originally Posted by greenlungs81 View Post
    i dont need them to be rar files but how would i add that to my code
    Perhaps you should tell us what you do need then. As I said, the Framework can handle ZIP files so if that's all you need then you don't have to use a third-party component.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Re: Download rar/zip file and extract to a certain folder

    ill just use zip files then how can i do it

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Download rar/zip file and extract to a certain folder

    You can call the ZipFile.ExtractToDirectory method. Note that it requires .NET 4.5 or later.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Re: Download rar/zip file and extract to a certain folder

    ok after it extracts how do i get it to delete the zip file

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Download rar/zip file and extract to a certain folder

    Quote Originally Posted by greenlungs81 View Post
    ok after it extracts how do i get it to delete the zip file
    The same way you delete any file. If you want to know how to delete a file in VB.NET then do the obvious:

    https://www.google.com.au/search?q=d...A-aK8QeqgoGoCQ

    Look first, ask questions later. We're here for the difficult stuff, not so you don't have to bother searching for yourself.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Re: Download rar/zip file and extract to a certain folder

    if you think i don't search before i post then your wrong i always do but every thing i tried didn't work
    i still cant figure out how to get it to extract and if you didnt know im new with vb
    Last edited by greenlungs81; Sep 24th, 2014 at 02:40 AM.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Download rar/zip file and extract to a certain folder

    Quote Originally Posted by greenlungs81 View Post
    if you think i don't search before i post then your wrong i always do but every thing i tried didn't work
    i still cant figure out how to get it to extract and if you didnt know im new with vb
    I said that you should call the ZipFile.ExtractToDirectory method.

    https://www.google.com.au/search?q=Z...FuTC8geyooCADg

    The very first result is the MSDN documentation for the method.

    http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx

    There are many more matches besides but that one includes a code example. Have you read that code example? If you really do search then you must have found it so what exactly do you not understand about it? It's a one-liner to extract from a ZIP file path to a folder path.

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Download rar/zip file and extract to a certain folder

    Are not all four of your threads similar?????

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Posts
    20

    Re: Download rar/zip file and extract to a certain folder

    not really im trying to find out how to extract a file when its done downloading then delete the zip file

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width