FileStream.CanSeek Property
.NET Framework 4
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 SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.