Removing complete directory path from zip archive

Jun 17, 2011 at 4:04 PM

Whenever I use the following code:

using (ZipFile zip = new ZipFile())
        {
            zip.AddFile(Server.MapPath("~//Images//Thumbs//1.png"));
            zip.AddFile(Server.MapPath("~//Images//Thumbs//2.png"));
            zip.AddFile(Server.MapPath("~//Images//Thumbs//3.png"));
            zip.Save(Server.MapPath("~//Images//Package.zip" ));
        }

to create a zip archive it produces a zip file but places the root files inside the full path of folders.

How can I create a zip archive and remove all the containing folders?

Thanks in advance.

Coordinator
Jun 18, 2011 at 7:00 AM

This is a FAQ.

Use the AddFile overload that accepts a second parameter, a string.  Pass "" (the empty string).

Check the documentation or the examples page on this website - the idea is explained in some detail.