ZipArchive.Dispose 方法

定义

释放由 ZipArchive 对象使用的所有资源。Releases all resources used by the ZipArchive object.

重载

Dispose()

释放 ZipArchive 类的当前实例使用的资源。Releases the resources used by the current instance of the ZipArchive class.

Dispose(Boolean)

Dispose()Finalize() 方法调用,以释放 ZipArchive 类的当前实例使用的未托管资源,并选择性地完成存档的写入和释放托管资源。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()

释放 ZipArchive 类的当前实例使用的资源。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 ()

实现

注解

此方法完成写入存档并释放 ZipArchive 对象使用的所有资源。This method finishes writing the archive and releases all resources used by the ZipArchive object. 除非使用 ZipArchive(Stream, ZipArchiveMode, Boolean) 构造函数重载构造对象并将其 leaveOpen 参数设置为 true,否则,所有基础流都将关闭,并且不再可用于后续写入操作。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.

使用完 ZipArchive的实例后,调用 Dispose() 释放此实例使用的所有资源。When you are finished using this instance of ZipArchive, call Dispose() to release all resources used by this instance. 你应消除对此 ZipArchive 实例的进一步引用,以便垃圾回收器可以回收实例的内存,而不是使其处于活动状态以完成操作。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() 调用 Dispose(Boolean) 方法,其中包含用于释放托管资源和非托管资源的代码。Dispose() calls the Dispose(Boolean) method, which contains the code to release managed and unmanaged resources. 有关详细信息,请参阅实现 Dispose 方法For more information, see Implementing a Dispose method.

Dispose(Boolean)

Dispose()Finalize() 方法调用,以释放 ZipArchive 类的当前实例使用的未托管资源,并选择性地完成存档的写入和释放托管资源。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)

参数

disposing
Boolean

true 表示完成存档的写入并释放未托管和托管资源;false 则仅释放未托管资源。true to finish writing the archive and release unmanaged and managed resources; false to release only unmanaged resources.

注解

如果 disposing 设置为 true,则所有基础流都将关闭,并且不再可用于后续写入操作,除非你使用 ZipArchive(Stream, ZipArchiveMode, Boolean) 构造函数重载构造对象并将其 leaveOpen 参数设置为 trueIf 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.

此方法仅由公共 Dispose()Finalize() 方法调用;请勿直接调用此方法。This method is called only by the public Dispose() and Finalize() methods; do not call this method directly.

实现 dispose 模式时,应按如下所示使用 Dispose(Boolean) 方法的布尔参数:When you implement the dispose pattern, the Boolean parameter of the Dispose(Boolean) method should be used as follows:

  • 当前对象的 Dispose() 方法应调用 Dispose(Boolean) 并将布尔参数设置为 true,以释放托管资源和非托管资源。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.

  • 当前对象的 Finalize() 方法应调用 Dispose(Boolean) 将布尔参数设置为 false,以仅释放非托管资源。The Finalize() method of the current object should call Dispose(Boolean) with the Boolean parameter set to false to release only unmanaged resources.

有关详细信息,请参阅实现 Dispose 方法For more information, see Implementing a Dispose method.

适用于