I have a method which performs zipping. I took the zipping code found on the net and modified it to make sure that folders can be zipped as well.
When using the code to zip a folder, it always produces an exception. Yet, the strange thing is that the code still manages to zip the folder correctly. I can view the contents of the zipped folder and unzip it.
There is no such problem if the zipping is done on a file.
The code is shown below:
I guess it is the code within the elseif(file.isDirectory()) clause which cause the exception but I cant figure out which line is the culprit, especially when the folder still manages to be zipped correctly.
I mentioned that the error is in the SourcingPerformZip function. As the source code for that is missing so can't comment perfectly about error. But, the error is that in this function when you get hold of a folder you are iterating foreach file. Now once the zip is being made all the files that were zipped are not getting binded to the zip created. Thus there occurs a blank zip with no files in it.
Just try to modify your code and add the zipped files to zip over the iteration. I think that should solve the problem.
Otherwise the code is attaching the files without zipping them so that can also be problematic.
Whatever the case you are doing something wrong with ZipEntry
Hope that helps. [ April 03, 2008: Message edited by: Anubhav Anand ]