Class ZArchiveLoadOptions

Class ZArchiveLoadOptions

Namespace: Aspose.Zip.Z
Assembly: Aspose.Zip.dll (25.7.0)

Options with which Aspose.Zip.Z.ZArchive is loaded from a compressed file. Contains event raised on extraction.

public class ZArchiveLoadOptions

Inheritance

object ZArchiveLoadOptions

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

ZArchiveLoadOptions()

public ZArchiveLoadOptions()

Properties

CancellationToken

Gets or sets a cancellation token used to cancel the extraction operation.

public CancellationToken CancellationToken { get; set; }

Property Value

CancellationToken

Examples

Cancel Z archive extraction after a certain time.

using (CancellationTokenSource cts = new CancellationTokenSource())
{
    cts.CancelAfter(TimeSpan.FromSeconds(60)); 
    using (var a = new ZArchive("big.z", new ZArchiveLoadOptions() { CancellationToken = cts.Token }))
    {
        try
        {
             a.Extract("data.bin");
        }
        catch(OperationCanceledException)
        {
            Console.WriteLine("Extraction was cancelled after 60 seconds");
        }
    }
}
```<p>
Using with <code>Task</code>
```csharp
CancellationTokenSource cts = new CancellationTokenSource();
                                               cts.CancelAfter(TimeSpan.FromSeconds(60));
                                               Task t = Task.Run(delegate()
                                               {
                                                   var loadOptions = new ZArchiveLoadOptions() { CancellationToken = cts.Token };
                                                   using (var a = ZArchive("big.z", loadOptions))
                                                   {
                                                        a.ExtractToDirectory("destination");
                                                   }
                                               }, cts.Token);

                                               t.ContinueWith(delegate(Task antecedent)
                                               {
                                                    if (antecedent.IsCanceled)
                                                    {
                                                        Console.WriteLine("Extraction was cancelled after 60 seconds");
                                                    }

                                                    cts.Dispose();
                                               });
```</p>
Cancellation mostly results in some data not being extracted.

#### Remarks

This property exists for .NET Framework 4.0 and above.

### <a id="Aspose_Zip_Z_ZArchiveLoadOptions_ExtractionProgressed"></a> ExtractionProgressed

Gets or sets the delegate invoked when some bytes have been extracted.

```csharp
public event EventHandler<progresseventargs> ExtractionProgressed

Event Type

EventHandler < ProgressEventArgs &gt;

Examples

ZArchive archive = new ZArchive("archive.z", 
new ZArchiveLoadOptions() { EntryExtractionProgressed = (s, e) =&gt; { int percent = (int)((100 * e.ProceededBytes) / length); } })

Remarks

Event sender is the Aspose.Zip.Z.ZArchive instance which extraction is progressed.

 English