Sets the current position of this stream to the given value.
Assembly: mscorlib (in mscorlib.dll)
abstract Seek : offset:int64 * origin:SeekOrigin -> int64 override Seek : offset:int64 * origin:SeekOrigin -> int64
- Type: System.Int64
The point relative to origin from which to begin seeking.
Return ValueType: System.Int64
The new position in the stream.
An I/O error occurred.
The stream does not support seeking, such as if the FileStream is constructed from a pipe or console output.
Seeking is attempted before the beginning of the stream.
Methods were called after the stream was closed.
This method overrides Stream.Seek.
You can seek to any location beyond the length of the stream. When you seek beyond the length of the file, the file size grows. In Windows NT and later versions, data added to the end of the file is set to zero. In Windows 98 or earlier versions, data added to the end of the file is not set to zero, which means that previously deleted data is visible to the stream.
For a list of common file and directory operations, see Common I/O Tasks.
The following example shows how to write data to a file, byte by byte, and then verify that the data was written correctly.
The following example reads text in the reverse direction, from the end of file to the beginning of the file, by using the various SeekOrigin values with the method.