Windows apps
Collapse the table of content
Expand the table of content
Information
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.

MemoryStream.WriteTo Method

Writes the entire contents of this memory stream to another stream.

[Visual Basic]
Public Overridable Sub WriteTo( _
   ByVal stream As Stream _
)
[C#]
public virtual void WriteTo(
 Stream stream
);
[C++]
public: virtual void WriteTo(
 Stream* stream
);
[JScript]
public function WriteTo(
   stream : Stream
);

Parameters

stream
The stream to write this memory stream to.

Exceptions

Exception Type Condition
ArgumentNullException stream is a null reference (Nothing in Visual Basic).
ObjectDisposedException The current or target stream is closed.

Remarks

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.

When the current stream is open, this method is equivalent to calling Stream.Write on the underlying buffer of this stream.

Requirements

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

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

Show:
© 2017 Microsoft