FileStream.CanSeek Property
.NET Framework (current version)
Gets a value indicating whether the current stream supports seeking.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Booleantrue if the stream supports seeking; false if the stream is closed or if the FileStream was constructed from an operating-system handle such as a pipe or output to the console.
The following example uses the CanSeek property to check whether a stream supports seeking.
Imports System Imports System.IO Public Class Test Public Shared Sub Main() Dim path As String = "c:\temp\MyTest.txt" ' Delete the file if it exists. If File.Exists(path) Then File.Delete(path) End If 'Create the file. Dim fs As FileStream = File.Create(path) If fs.CanSeek Then Console.WriteLine("The stream connected to {0} is seekable.", path) Else Console.WriteLine("The stream connected to {0} is not seekable.", path) End If fs.Close() End Sub End Class
Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Show: