MemoryStream.Write 메서드

정의

오버로드

Write(ReadOnlySpan<Byte>)

source에 포함된 바이트의 시퀀스를 현재의 메모리 스트림에 쓰고, 이 메모리 스트림 내에서 기록한 바이트 수만큼 현재 위치를 앞으로 이동합니다.

Write(Byte[], Int32, Int32)

버퍼에서 읽은 데이터를 사용하여 현재 스트림에 바이트 블록을 씁니다.

Write(ReadOnlySpan<Byte>)

source에 포함된 바이트의 시퀀스를 현재의 메모리 스트림에 쓰고, 이 메모리 스트림 내에서 기록한 바이트 수만큼 현재 위치를 앞으로 이동합니다.

public:
 override void Write(ReadOnlySpan<System::Byte> source);
public:
 override void Write(ReadOnlySpan<System::Byte> buffer);
public override void Write (ReadOnlySpan<byte> source);
public override void Write (ReadOnlySpan<byte> buffer);
override this.Write : ReadOnlySpan<byte> -> unit
override this.Write : ReadOnlySpan<byte> -> unit
Public Overrides Sub Write (source As ReadOnlySpan(Of Byte))
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Byte))

매개 변수

sourcebuffer
ReadOnlySpan<Byte>

메모리 영역입니다. 이 메서드는 이 영역의 콘텐츠를 현재의 메모리 스트림에 복사합니다.

적용 대상

Write(Byte[], Int32, Int32)

버퍼에서 읽은 데이터를 사용하여 현재 스트림에 바이트 블록을 씁니다.

public:
 override void Write(cli::array <System::Byte> ^ buffer, int offset, int count);
public override void Write (byte[] buffer, int offset, int count);
override this.Write : byte[] * int * int -> unit
Public Overrides Sub Write (buffer As Byte(), offset As Integer, count As Integer)

매개 변수

buffer
Byte[]

데이터를 쓸 버퍼입니다.

offset
Int32

현재 스트림으로 바이트를 복사하기 시작할 buffer의 바이트 오프셋(0부터 시작)입니다.

count
Int32

쓸 최대 바이트 수입니다.

예외

buffer이(가) null인 경우

스트림이 쓰기를 지원하지 않습니다. 자세한 내용은 CanWrite를 참조하십시오.

또는 현재 위치가 스트림의 끝에서 count 바이트보다 가까우며 용량을 수정할 수 없는 경우

버퍼 길이에서 offset을 빼면 count보다 작은 경우

offset 또는 count가 음수인 경우

I/O 오류가 발생했습니다.

현재 스트림 인스턴스가 닫혀 있는 경우

예제

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 MemoryStream 클래스입니다.

// Write the first string to the stream.
memStream->Write( firstString, 0, firstString->Length );
// Write the first string to the stream.
memStream.Write(firstString, 0 , firstString.Length);
' Write the first string to the stream.
memStream.Write(firstString, 0 , firstString.Length)

설명

이 메서드는 Write를 재정의합니다.

매개 변수는 offset 쓸 첫 번째 바이트의 buffer 오프셋을 제공하고 매개 변수는 count 쓸 바이트 수를 제공합니다. 쓰기 작업이 성공하면 스트림 내의 현재 위치는 기록된 바이트 수만큼 진행됩니다. 예외가 발생하면 스트림 내의 현재 위치는 변경되지 않습니다.

MemoryStream byte[] 매개 변수를 사용하여 생성된 경우를 제외하고 확장MemoryStreamMemoryStream 끝에 작업을 씁니다.

추가 정보

적용 대상