User (Old forums)MemberApril 3, 2007 at 11:21 amPost count: 23064
I have an array of Files and Folders. I want to compress them all into a single zip file. I’d like to use Events to drive a progress bar and give the user the option to cancel. In theory, the target zip file could be quite huge depending on the depth and contents of folders.
Here is what I’m missing:
A) How to CANCEL zip operation that is in progress if it is taking to long for the user’s liking?
B) How to make sure the zip file is flushed and closed immediately? I don’t see a ZipArchive.Close or DiskFile.Close / Flush methods?
C) It looks like files are copied to temp folder before Zipping. Which event handlers are used to track progress % for this stage? Is there an option not to use a temp folder and just go straight to zipping? (I’m only creating new ZipFiles, never removing or adding contents).
Please see my code:
// Setup Handlers
ZipEvents events = new ZipEvents();
events.BuildingZipByteProgression += new BuildingZipByteProgressionEventHandler(OnZipByteProgression);
events.BuildingZipItemProgression += new BuildingZipItemProgressionEventHandler(OnZipItemProgression);
events.ItemException += new ItemExceptionEventHandler(OnZipItemException);
foreach (string ZipItem in m_FilesAndFolders)
// TODO: What if you try to add the same folder name twice?
ZipItems[NumItemsSoFar++] = new Xceed.FileSystem.DiskFolder(ZipItem);
ZipItems[NumItemsSoFar++] = new Xceed.FileSystem.DiskFile(ZipItem);
// We’ve got our objects in Xceed’s vocabulary now, lets zip away!
using ( new AutoBatchUpdate ( MyZipArchive, events, this ) )
foreach (Xceed.FileSystem.FileSystemItem item in ZipItems)
Event handlers return Void so how can you cancel a zip in progress?
Imported from legacy forums. Posted by DaveHaxxor (had 2203 views)User (Old forums)MemberApril 3, 2007 at 3:18 pmPost count: 23064
A) Here is a link to a developer blog that shows how to abort a zip operation :
B) The same blog shows how to properly clean up when aborting.
C) Use the GatheringZipContentByteProgression event for the temp folder stage. It is not possible NOT to use this temporary step. It can be done in memory instead of on disk (which is usually not a good idea when dealing with big files), but it is a required step.
Imported from legacy forums. Posted by André (had 3035 views)
- You must be logged in to reply to this topic.