[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
Re: Zipping an entire folder content ( with folders and files)
have you looked at the methods available to the zip object (intellisense)?
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
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
Re: Zipping an entire folder content ( with folders and files)
Thanks mate, the 2nd link helped me figure it out.
Cheers,
Mike