|
-
Aug 19th, 2012, 06:29 PM
#1
Thread Starter
Lively Member
[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
-
Aug 19th, 2012, 06:47 PM
#2
Re: Zipping an entire folder content ( with folders and files)
have you looked at the methods available to the zip object (intellisense)?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Aug 19th, 2012, 07:20 PM
#3
Thread Starter
Lively Member
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
-
Aug 19th, 2012, 10:08 PM
#4
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
-
Aug 20th, 2012, 09:19 AM
#5
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|