MemoryStream.CopyTo(Stream, Int32) 方法

定義

使用指定的緩衝區大小,從目前記憶體資料流讀取位元組,並將其寫入至另一個資料流。Reads the bytes from the current memory stream and writes them to another stream, using a specified buffer size.

public:
 override void CopyTo(System::IO::Stream ^ destination, int bufferSize);
public override void CopyTo (System.IO.Stream destination, int bufferSize);
override this.CopyTo : System.IO.Stream * int -> unit
Public Overrides Sub CopyTo (destination As Stream, bufferSize As Integer)

參數

destination
Stream

要將目前記憶體資料流內容複製到其中的資料流。The stream to which the contents of the current memory stream will be copied.

bufferSize
Int32

緩衝區的大小。The size of the buffer. 這個值必須大於零。This value must be greater than zero. 預設大小為 81920。The default size is 81920.

例外狀況

destinationnulldestination is null.

bufferSize 不是正數。bufferSize is not a positive number.

基礎記憶體資料流或 destination 資料流已關閉。Either the underlying memory stream or the destination stream is closed.

無法讀取基礎記憶體資料流。The underlying memory stream is unreadable.

-或--or-

無法寫入 destination 資料流。The destination stream is unwritable.

適用於