FileStream::CanSeek Property
.NET Framework 4.5
Gets a value indicating whether the current stream supports seeking.
Namespace: System.IO
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.
using namespace System; using namespace System::IO; using namespace System::Text; int main() { String^ path = "c:\\temp\\MyTest.txt"; // Delete the file if it exists. if ( File::Exists( path ) ) { File::Delete( path ); } //Create the file. FileStream^ fs = File::Create( path ); try { 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 ); } } finally { if ( fs ) delete (IDisposable^)fs; } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.