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()

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

public void Dispose ();

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 .

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.

protected virtual void Dispose (bool disposing);
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 .

Applies to