Results 1 to 5 of 5

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

  1. #1
    Lively Member
    Join Date
    Jul 12
    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

  3. #3
    Lively Member
    Join Date
    Jul 12
    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 02
    Posts
    21,655

    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 subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * 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??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  5. #5
    Lively Member
    Join Date
    Jul 12
    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
  •