Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Aborting long operations?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19783 |

    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)
    {
    if (STPClient.IsAFolder(ZipItem))
    {
    // TODO: What if you try to add the same folder name twice?
    ZipItems[NumItemsSoFar++] = new Xceed.FileSystem.DiskFolder(ZipItem);
    }
    else
    {
    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)
    {
    item.CopyTo(MyZipArchive, true);
    }
    }

    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)
    Member
    Post count: 23064

    A) Here is a link to a developer blog that shows how to abort a zip operation :

    http://blogs.xceedsoft.com/plantem/SearchView.aspx?q=aborting

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.