Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Cancel Archivation

To provide the capability to cancel an archiving process after it has been started, do the following:

  1. Create a ZipArchive class instance.
  2. Subscribe to the ZipArchive.Progress event.
  3. Set the CanContinueEventArgs.CanContinue property of event arguments to false, in case you decide to stop the operation.
  4. Call the ZipArchive.AddFile method for each selected file.
  5. Call the ZipArchive.Save method to create an archive and save it to a specified location.

View Example

using DevExpress.Compression;
        volatile bool stopProgress = false;

        public void CancelArchiveProgress() {
            string[] sourcefiles = this.sourceFiles;
            using (ZipArchive archive = new ZipArchive()) {
                archive.Progress += archive_Progress;
                foreach (string file in sourceFiles) {
                    archive.AddFile(file, "/");
                }
                archive.Save("Documents\\CancelArchiveProgress.zip");
            }
        }

        private void archive_Progress(object sender, ProgressEventArgs args) {
            args.CanContinue = !this.stopProgress;
        }