MemoryStream.Write 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
오버로드
Write(ReadOnlySpan<Byte>) |
|
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[] 매개 변수를 사용하여 생성된 경우를 제외하고 확장MemoryStream
의 MemoryStream
끝에 작업을 씁니다.