Class OdfDirectIoWritableStream
Provides a write-only stream optimized for Direct I/O file access when the platform supports it. 提供在平台支援時使用 Direct I/O 檔案存取最佳化的唯寫資料流。
public sealed class OdfDirectIoWritableStream : Stream, IDisposable, IAsyncDisposable
- Inheritance
-
OdfDirectIoWritableStream
- Implements
- Inherited Members
Constructors
OdfDirectIoWritableStream(string)
Initializes a new instance of the OdfDirectIoWritableStream class. 初始化 OdfDirectIoWritableStream 類別的新執行個體。
public OdfDirectIoWritableStream(string filePath)
Parameters
filePathstringThe path of the file to write. / 要寫入的檔案路徑。
Remarks
與 OdfDirectIoReadableStream 同理:對齊原生緩衝區依 CA2015 沒有 GC 備援釋放, 建構子拋出時呼叫端拿不到執行個體、無從 Dispose,因此必須自行清理。此處的觸發點是後備路徑的 FileStream 建構——Create 對不存在的目錄會擲出 DirectoryNotFoundException,並非罕見情境。
Properties
CanRead
Provides the CanRead member. 提供 CanRead 成員。
public override bool CanRead { get; }
Property Value
CanSeek
Provides the CanSeek member. 提供 CanSeek 成員。
public override bool CanSeek { get; }
Property Value
CanWrite
Provides the CanWrite member. 提供 CanWrite 成員。
public override bool CanWrite { get; }
Property Value
Length
Performs length. 執行 Length。
public override long Length { get; }
Property Value
Position
Gets the number of bytes accepted by the stream. 取得資料流已接受的位元組數。
public override long Position { get; set; }
Property Value
Methods
Dispose(bool)
Releases unmanaged resources. 釋放非受控資源。
protected override void Dispose(bool disposing)
Parameters
disposingbool
Flush()
Performs flush. 執行 Flush。
public override void Flush()
Read(byte[], int, int)
Performs the Read operation. 執行 Read 作業。
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
Seek(long, SeekOrigin)
Performs seek. 執行 Seek。
public override long Seek(long offset, SeekOrigin origin)
Parameters
offsetlongoriginSeekOrigin
Returns
SetLength(long)
Sets length. 設定 Length。
public override void SetLength(long value)
Parameters
valuelong
Write(byte[], int, int)
Performs the Write operation. 執行 Write 作業。
public override void Write(byte[] buffer, int offset, int count)
Parameters
Write(ReadOnlySpan<byte>)
Writes a span directly to the underlying stream. 將唯讀範圍直接寫入底層資料流。
public override void Write(ReadOnlySpan<byte> buffer)
Parameters
bufferReadOnlySpan<byte>
WriteAsync(byte[], int, int, CancellationToken)
Writes async. 寫入 Async。
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
bufferbyte[]offsetintcountintcancellationTokenCancellationToken
Returns
WriteAsync(ReadOnlyMemory<byte>)
Writes the buffer asynchronously without cancellation. 在不可取消的情況下非同步寫入緩衝區。
public ValueTask WriteAsync(ReadOnlyMemory<byte> buffer)
Parameters
bufferReadOnlyMemory<byte>The buffer to write. / 要寫入的緩衝區。
Returns
- ValueTask
A value task representing the write operation. / 代表寫入作業的值工作。
WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
Writes a memory buffer asynchronously. 非同步寫入記憶體緩衝區。
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
Parameters
bufferReadOnlyMemory<byte>cancellationTokenCancellationToken