次の方法で共有


Stream.CopyTo Method (Stream, Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Reads all the bytes from the current stream and writes them to a destination stream, using a specified buffer size.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Sub CopyTo ( _
    destination As Stream, _
    bufferSize As Integer _
)
public void CopyTo(
    Stream destination,
    int bufferSize
)

Parameters

  • destination
    Type: System.IO.Stream
    The stream that will contain the contents of the current stream.
  • bufferSize
    Type: System.Int32
    The size of the buffer. This value must be greater than zero. The default size is 4096.

Exceptions

Exception Condition
ArgumentNullException

destination is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

bufferSize is negative or zero.

NotSupportedException

The current stream does not support reading.

-or-

destination does not support writing.

ObjectDisposedException

Either the current stream or destination were closed before the CopyTo method was called.

IOException

An I/O error occurred.

Remarks

Copying begins at the current position in the current stream.

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.