Skip to main content

ZipArchive.Progress Event

Occurs evenly while the items are being compressed to indicate progress.

Namespace: DevExpress.Compression

Assembly: DevExpress.Docs.v24.1.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public event ProgressEventHandler Progress

Event Data

The Progress event's data class is ProgressEventArgs. The following properties provide information specific to this event:

Property Description
CanContinue Gets or sets the value that specifies whether the process can proceed further. Inherited from CanContinueEventArgs.
Progress Obtains the progress value.

Remarks

By handling the Progress event, you can obtain information about the progress of zipping the archive items. You can also interrupt archive creation by setting the CanContinueEventArgs.CanContinue value to false. After that, the archive is saved with all items which have been zipped to that point and the process is finished.

The following code snippet illustrates how you can use the volatile variable to interrupt archive creation at any time. When the Progress event occurs, the event handler checks for the stopProgress value. If it is true, the process stops.

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;
        }

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Progress event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also