ZipArchive.Dispose Method

Definition

Releases all resources used by the ZipArchive object.

Overloads

Dispose()

Releases the resources used by the current instance of the ZipArchive class.

Dispose(Boolean)

Called by the Dispose() and Finalize() methods to release the unmanaged resources used by the current instance of the ZipArchive class, and optionally finishes writing the archive and releases the managed resources.

Dispose()

Source:
ZipArchive.cs
Source:
ZipArchive.cs
Source:
ZipArchive.cs

Releases the resources used by the current instance of the ZipArchive class.

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

Implements

Remarks

This method finishes writing the archive and releases all resources used by the ZipArchive object. Unless you construct the object by using the ZipArchive(Stream, ZipArchiveMode, Boolean) constructor overload and set its leaveOpen parameter to true, all underlying streams are closed and no longer available for subsequent write operations.

When you are finished using this instance of ZipArchive, call Dispose() to release all resources used by this instance. You should eliminate further references to this ZipArchive instance so that the garbage collector can reclaim the memory of the instance instead of keeping it alive for finalization.

Dispose() calls the Dispose(Boolean) method, which contains the code to release managed and unmanaged resources. For more information, see Implementing a Dispose method.

Applies to

Dispose(Boolean)

Source:
ZipArchive.cs
Source:
ZipArchive.cs
Source:
ZipArchive.cs

Called by the Dispose() and Finalize() methods to release the unmanaged resources used by the current instance of the ZipArchive class, and optionally finishes writing the archive and releases the managed resources.

protected:
 virtual void Dispose(bool disposing);
protected virtual void Dispose (bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (disposing As Boolean)

Parameters

disposing
Boolean

true to finish writing the archive and release unmanaged and managed resources; false to release only unmanaged resources.

Remarks

If disposing is set to true, all underlying streams are closed and no longer available for subsequent write operations, unless you construct the object by using the ZipArchive(Stream, ZipArchiveMode, Boolean) constructor overload and set its leaveOpen parameter to true.

This method is called only by the public Dispose() and Finalize() methods; do not call this method directly.

When you implement the dispose pattern, the Boolean parameter of the Dispose(Boolean) method should be used as follows:

  • The Dispose() method of the current object should call Dispose(Boolean) with the Boolean parameter set to true to release both managed and unmanaged resources.

  • The Finalize() method of the current object should call Dispose(Boolean) with the Boolean parameter set to false to release only unmanaged resources.

For more information, see Implementing a Dispose method.

Applies to