Insert FOLDER into .zip file instead of seperate files.

Oct 25, 2010 at 11:41 PM

Hey guys.

I've only been coding for under 2 months now, and I'm working on a program.

Basically it has a built in FTP uploader, so DotNetZip will put any screenshots taken, into a single .zip folder, then that .zip folder will be uploaded to the ftp server.

However, when the screenshots are taken, they are called "screenshot*randomnumber*.bmp" so obviously, i cannot tell the the uploader to upload specific files as they will have different random names all the time.

So basically I was wondering how I could make it zip the folder itself into a .zip.

This is what I have so far:

Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        'Create Zip File
        Using zip As ZipFile = New ZipFile()
            zip.AddFile("M:\ESP Anti-Cheat BETA v0.1\screenshot30707.bmp")
        End Using
And obviously here something needs to be done with the zip.AddFile to convert it to zip.AddFolder or something similar.


Thanks in advance!

Oct 27, 2010 at 12:12 AM
Edited Oct 27, 2010 at 12:13 AM

Instead of calling zip.AddFile(), try calling zip.AddDirectory(), and specify the name of the directory to add into the zip file.

There are several overloads of this method. Check the DotNetZip documentation to help you decide which of them to choose.

 ps: welcome to the wonderful world of computer programming!