FileStream.CanSeek Property
.NET Framework 3.5
Gets a value indicating whether the current stream supports seeking.
Assembly: mscorlib (in mscorlib.dll)
The following example uses the CanSeek property to check whether a stream supports seeking.
using System; using System.IO; using System.Text; class Test { public static void Main() { string path = @"c:\temp\MyTest.txt"; // Delete the file if it exists. if (File.Exists(path)) { File.Delete(path); } //Create the file. using (FileStream fs = File.Create(path)) { if (fs.CanSeek) { Console.WriteLine("The stream connected to {0} is seekable.", path); } else { Console.WriteLine("The stream connected to {0} is not seekable.", path); } } } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.