How to zip without saving the directory info?

Jul 6, 2008 at 2:53 AM
Hi,

First of all I would like to thank you for the wonderful utility you have created ! Keep the great work going !

I was wondering if there is a way to zip a file without the directory structure of that file. Basically, when I zip the file c:\test1\test2\file1.doc, and then unzip it to say D:\test3, it creates the following directory structure D:\test3\test1\test2, and extracts it there.
Here is the code I am using

Zip
                ZipFile file = new ZipFile();
                file.Password = "password";
                file.AddFile("file1.doc");
                file.Save("test.zip");
Unzip

                 ZipFile file = new ZipFile("test.zip");
                 file[file.EntryFilenames[0]].ExtractWithPassword("password");

Many thanks !
Sameer

p.s. I am using release 1.5
Jul 6, 2008 at 2:55 AM
Edited Jul 6, 2008 at 3:03 AM
Just realized I need to set the second argument to AddFile as "".
file.AddFile("file1.doc","");

This solves my problem.
Coordinator
Jul 6, 2008 at 4:06 PM

Yes, you found the answer.  I'm glad DotNetZip is working for you.

Just a reminder - DotNetZip is donationware.  If you like it, consider donating. Completely voluntary.