Language

RandomAccess.Write Method

Definition

Overloads

Name Description
Write(SafeFileHandle, IReadOnlyList<ReadOnlyMemory<Byte>>, Int64)

Writes a sequence of bytes from given buffers to given file at given offset.

Write(SafeFileHandle, ReadOnlySpan<Byte>, Int64)

Writes a sequence of bytes from given buffer to given file at given offset.

Write(SafeFileHandle, IReadOnlyList<ReadOnlyMemory<Byte>>, Int64)

Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs

Writes a sequence of bytes from given buffers to given file at given offset.

public:
 static void Write(Microsoft::Win32::SafeHandles::SafeFileHandle ^ handle, System::Collections::Generic::IReadOnlyList<ReadOnlyMemory<System::Byte>> ^ buffers, long fileOffset);
public static void Write(Microsoft.Win32.SafeHandles.SafeFileHandle handle, System.Collections.Generic.IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset);
static member Write : Microsoft.Win32.SafeHandles.SafeFileHandle * System.Collections.Generic.IReadOnlyList<ReadOnlyMemory<byte>> * int64 -> unit
Public Shared Sub Write (handle As SafeFileHandle, buffers As IReadOnlyList(Of ReadOnlyMemory(Of Byte)), fileOffset As Long)

Parameters

handle
SafeFileHandle

The file handle.

buffers
IReadOnlyList<ReadOnlyMemory<Byte>>

A list of memory buffers. This method copies the contents of these buffers to the file.

fileOffset
Int64

The file position to write to. In .NET 11 and later versions, this parameter is ignored for files that don't support seeking, such as pipes, sockets, and character devices. The value must be non-negative even when it's ignored.

Exceptions

handle or buffers is null.

handle is invalid.

The file is closed.

In .NET 10 and earlier versions, the file doesn't support seeking (for example, a pipe or socket).

fileOffset is negative.

handle was not opened for writing.

An I/O error occurred.

Remarks

For files that support seeking, the file position is not advanced.

Applies to

Write(SafeFileHandle, ReadOnlySpan<Byte>, Int64)

Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs
Source:
RandomAccess.cs

Writes a sequence of bytes from given buffer to given file at given offset.

public:
 static void Write(Microsoft::Win32::SafeHandles::SafeFileHandle ^ handle, ReadOnlySpan<System::Byte> buffer, long fileOffset);
public static void Write(Microsoft.Win32.SafeHandles.SafeFileHandle handle, ReadOnlySpan<byte> buffer, long fileOffset);
static member Write : Microsoft.Win32.SafeHandles.SafeFileHandle * ReadOnlySpan<byte> * int64 -> unit
Public Shared Sub Write (handle As SafeFileHandle, buffer As ReadOnlySpan(Of Byte), fileOffset As Long)

Parameters

handle
SafeFileHandle

The file handle.

buffer
ReadOnlySpan<Byte>

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

fileOffset
Int64

The file position to write to. In .NET 11 and later versions, this parameter is ignored for files that don't support seeking, such as pipes, sockets, and character devices. The value must be non-negative even when it's ignored.

Exceptions

handle is null.

handle is invalid.

The file is closed.

In .NET 10 and earlier versions, the file doesn't support seeking (for example, a pipe or socket).

fileOffset is negative.

handle was not opened for writing.

An I/O error occurred.

Remarks

For files that support seeking, the file position is not advanced.

Applies to