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 的类不支持查找,则调用 LengthSetLengthPositionSeek 将引发 NotSupportedException

如果流关闭,此属性返回 false

适用于

另请参阅