BufferedStream.CanSeek 属性
定义
获取一个值,该值指示当前流是否支持查找。Gets a value indicating whether the current stream supports seeking.
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。true if the stream supports seeking; false if the stream is closed or if the stream was constructed from an operating system handle such as a pipe or output to the console.
示例
此代码示例是为类提供的更大示例的一部分 BufferedStream 。This code example is part of a larger example provided for the BufferedStream class.
// 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.
If bufStream.CanSeek Then
Console.WriteLine("NetworkStream supports" & _
"seeking." & vbCrLf)
Else
Console.WriteLine("NetworkStream does not " & _
"support seeking." & vbCrLf)
End If
注解
如果从派生的类 Stream 不支持查找,则调用 Length 、、 SetLength 和将 Position Seek 引发 NotSupportedException 。If a class derived from Stream does not support seeking, calls to Length, SetLength, Position, and Seek throw a NotSupportedException.
如果流已关闭,则此属性返回 false 。If the stream is closed, this property returns false.