This project is read-only.

avoid folder structure in zip file?

Aug 1, 2010 at 12:36 PM
Edited Aug 1, 2010 at 12:40 PM


when i create the zipfile from my application, i use

zip.AddFile(Server.MapPath(("\\Data\\Files\\Division\\SubDivision\\" + fn)); 


and then i do the save,
zip.Save(Server.MapPath("\\Data\\Files\\Division\\SubDivision\\" + fn + ".zip").ToString());
the file gets added to the zip, the zip saves fine and i m able to download it. the issue i am facing is,
the file with filename "fn" is stored in the \Data\Files\Division\SubDivision\fn.docx folder. now in the zip file,
i want only the fn.docx and the whole sub diretory structure from my root.

when the zip is created, the folder structure inside the zip file is Data\Files\Division\SubDivision\fn.docx. i want it to be only fn.docx.

can anybody help me pls?




Aug 10, 2010 at 9:38 AM
If you don't want the directory structure inside the zip, then add the zip files using zip.AddFile(sourceFilePath, "\\"); That way you get a zip file with the fn.docx in the root.