Removing directory inforamtion from zipped file

Apr 29, 2008 at 5:31 AM
I am using this excellent code to zip a file, which is then uploaded to a server and upzipped on the server. I am having problems in that the zipped file seems to carry the path information with it, and unattended unzipping in a totally different environment does not work.

The code for zipping is

//compress (zip) the file to speed transfer
//don't foget to unzip on site
//also store on site in zip format for archive
Ionic.Utils.Zip.ZipFile zfile = new ZipFile("");

and the code on the server (WS2003) is

protected void Page_Load(object sender, EventArgs e)
string appath = Request.PhysicalApplicationPath;
Ionic.Utils.Zip.ZipFile zfile = new ZipFile(appath + "/data/");
//unzip the file
zfile.Extract( appath + "/data/Data.mdb");

Any help in making this work would be greatly appreciated
Many Thanks
Jun 8, 2008 at 12:19 AM
There is an override method that allows you to specify the directory path for entries as you add them to the ZipFile.
Check the doc!

AddFile(Filename, DirectoryInArchive);

if you want the entry to be in the top-level dir in the archive, do this: 
AddFile(Filename, "");