共用方式為


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

屬性值

如果資料流支援搜尋則為 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 的類別不支援搜尋,則呼叫LengthSetLengthPosition、 和會Seek擲回 NotSupportedException

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

適用於

另請參閱