If offset is positive, the new position is required to follow the position specified by origin by the number of bytes specified by offset. Classes derived from Stream that support seeking must override this method to provide the functionality described above. Seeking to any location beyond the length of the stream is supported.
On devices incapable of seeking, the return value is undefined. If stream is a null pointer, or if origin isn't one of allowed values described below, fseek and _fseeki64 invoke the invalid parameter handler, as described in Parameter validation. If execution is allowed to continue, these functions set errno to EINVAL and return -1.
Note Use the FileStream.CanSeek property to determine whether the current instance supports seeking. For additional information, see Stream.CanSeek. 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. Data added to the end of the file is set to zero.
Seeking to any location beyond the length of the stream is supported. Do not use the Seek method to determine the new position in the stream if the MemoryStream was initialized with a non-zero offset. If you do, Seek will return an inaccurate value. Instead, use the Position property to get the new position of the stream.
For streams that support seeking, use the Seek and SetLength methods and the Position and Length properties to query and modify the current position and length of a stream. This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly.