Editare

Partajați prin


Stream.Write Method

Definition

Overloads

Write(ReadOnlySpan<Byte>)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Write(Byte[], Int32, Int32)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Write(ReadOnlySpan<Byte>)

Source:
Stream.cs
Source:
Stream.cs
Source:
Stream.cs

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

public:
 virtual void Write(ReadOnlySpan<System::Byte> buffer);
public virtual void Write (ReadOnlySpan<byte> buffer);
abstract member Write : ReadOnlySpan<byte> -> unit
override this.Write : ReadOnlySpan<byte> -> unit
Public Overridable Sub Write (buffer As ReadOnlySpan(Of Byte))

Parameters

buffer
ReadOnlySpan<Byte>

A region of memory. This method copies the contents of this region to the current stream.

Remarks

Use the CanWrite property to determine whether the current instance supports writing. Use the WriteAsync method to write asynchronously to the current stream.

If the write operation is successful, the position within the stream advances by the number of bytes written. If an exception occurs, the position within the stream remains unchanged.

Applies to

Write(Byte[], Int32, Int32)

Source:
Stream.cs
Source:
Stream.cs
Source:
Stream.cs

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

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

Parameters

buffer
Byte[]

An array of bytes. This method copies count bytes from buffer to the current stream.

offset
Int32

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

count
Int32

The number of bytes to be written to the current stream.

Exceptions

The sum of offset and count is greater than the buffer length.

buffer is null.

offset or count is negative.

An I/O error occurred, such as the specified file cannot be found.

The stream does not support writing.

Write(Byte[], Int32, Int32) was called after the stream was closed.

Remarks

Use the CanWrite property to determine whether the current instance supports writing. Use the WriteAsync method to write asynchronously to the current stream.

If the write operation is successful, the position within the stream advances by the number of bytes written. If an exception occurs, the position within the stream remains unchanged.

See also

Applies to