BufferedStream.CanSeek 屬性

定義

取得表示目前資料流是否支援搜尋的值。

public:
 virtual property bool CanSeek { bool get(); };
public override bool CanSeek { get; }
member this.CanSeek : bool
Public Overrides ReadOnly Property CanSeek As Boolean

屬性值

Boolean

如果資料流支援搜尋則為 true;如果資料流關閉或如果資料流從作業系統控制代碼 (例如管道或主控台的輸出) 建構,則為 false

範例

此程式碼範例是提供給 類別之較大範例的 BufferedStream 一部分。

// Check whether the underlying stream supports seeking.
Console::WriteLine( "NetworkStream {0} seeking.\n", bufStream->CanSeek ? (String^)"supports" : "does not support" );
// Check whether the underlying stream supports seeking.
Console.WriteLine("NetworkStream {0} seeking.\n",
    bufStream.CanSeek ? "supports" : "does not support");
// Check whether the underlying stream supports seeking.
printfn $"""NetworkStream {if bufStream.CanSeek then "supports" else "does not support"} seeking.\n"""
' Check whether the underlying stream supports seeking.
If bufStream.CanSeek Then
    Console.WriteLine("NetworkStream supports" & _
        "seeking." & vbCrLf)
Else
    Console.WriteLine("NetworkStream does not " & _
        "support seeking." & vbCrLf)
End If

備註

如果衍生自 Stream 的類別不支援搜尋,則呼叫 LengthSetLength PositionSeek 會擲回 NotSupportedException

如果資料流程已關閉,這個屬性會傳 false 回 。

適用於

另請參閱