This documentation is archived and is not being maintained.

DeflateStream.EndWrite Method

Ends an asynchronous write operation.

Namespace: System.IO.Compression
Assembly: System (in system.dll)

virtual void EndWrite (
	IAsyncResult^ asyncResult
) override
public void EndWrite (
	IAsyncResult asyncResult
public override function EndWrite (
	asyncResult : IAsyncResult
Not applicable.



A reference to the outstanding asynchronous I/O request.

Exception typeCondition


asyncResult is a null reference (Nothing in Visual Basic).


asyncResult did not originate from a BeginWrite method on the current stream.


An exception was thrown during a call to WaitOne.


The stream is a null reference (Nothing in Visual Basic).


The end write call is invalid.

EndWrite must be called only once for every call to the BeginWrite method.

This method blocks until the I/O operation has completed. Errors that occur during an asynchronous write request, such as a disk failure during the I/O request, occur on the thread pool thread and become visible upon a call to EndWrite. Exceptions thrown by the thread pool thread will not be visible when calling EndWrite.

The following code example shows how to use the DeflateStream class to compress and decompress a file.


Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0