Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Stream.EndWrite Method

Ends an asynchronous write operation.

[Visual Basic]
Public Overridable Sub EndWrite( _
   ByVal asyncResult As IAsyncResult _
public virtual void EndWrite(
 IAsyncResult asyncResult
public: virtual void EndWrite(
 IAsyncResult* asyncResult
public function EndWrite(
   asyncResult : IAsyncResult


A reference to the outstanding asynchronous I/O request.


Exception Type Condition
ArgumentNullException asyncResult is a null reference (Nothing in Visual Basic).
ArgumentException asyncResult did not originate from a BeginWrite method on the current stream.


For an example of creating a file and writing text to a file, see Writing Text to a File. For an example of reading text from a file, see Reading Text from a File. For an example of reading from and writing to a binary file, see Reading and Writing to a Newly Created Data File. For an example of asynchronous file I/O, see Asynchronous File I/O.

EndWrite must be called exactly once on every IAsyncResult from BeginWrite.

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 threadpool thread and become visible upon a call to EndWrite. Exceptions thrown by the threadpool thread will not be visible when calling EndWrite.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Stream Class | Stream Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File | Asynchronous File I/O

© 2017 Microsoft