Results 1 to 5 of 5

Thread: [RESOLVED] Zipping an entire folder content ( with folders and files)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    111

    Resolved [RESOLVED] Zipping an entire folder content ( with folders and files)

    Hi guys I already added the DotNetZip library to my project, and reference the IonicZip .dll ,
    everything seems to be alright with that. I'm dont know how to zip an entire folder. I'm getting a blue line error
    on the line: "My.Computer.FileSystem.GetDirectories(pjDir )". ee


    Code:
     Private Sub Zipbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zipbtn.Click
            If FBDialog.ShowDialog = DialogResult.OK Then
                pjDir = FBDialog.SelectedPath
    
                If pjDir <> "" Then
                    Using zip As ZipFile = New ZipFile
                        Dim dirCnt As String = My.Computer.FileSystem.GetDirectories(pjDir )
    
                        For Each file In pjDir
                            zip.AddFile(file)
                        Next
                        zip.Save("MyZipFile.zip")
                    End Using
                End If
            End If
        End Sub
    I was just experimenting,
    I really dont know a way to zip a complete folder.

    Any light shed will be greatfull,
    Mike

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Zipping an entire folder content ( with folders and files)

    have you looked at the methods available to the zip object (intellisense)?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    111

    Re: Zipping an entire folder content ( with folders and files)

    Thanks for the tip.

    I used AddDirectory, but it doesn't do anything.

    Code:
    
      pjDir = FBDialog.SelectedPath
    
                If pjDir <> "" Then
                    Using zip As ZipFile = New ZipFile
                        zip.AddDirectory(pjDir)
                        zip.Save("MyZipFile.zip")
                    End Using
                End If

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Zipping an entire folder content ( with folders and files)

    What do you mean it doesn't do anything? What is pjDir?

    It looks like according to this page - http://dotnetzip.codeplex.com/wikipa...le=VB-examples that AddDirectory can take two parameters.... one is the full path of the directory to include, and the second is the name of the folder in the archive.

    Might also want to look through this... since you didn't say what didn't work, I don't know if it holds anything relevant to the issue.
    http://dotnetzip.codeplex.com/discussions/263945/

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    111

    Re: Zipping an entire folder content ( with folders and files)

    Thanks mate, the 2nd link helped me figure it out.

    Cheers,
    Mike

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