This documentation is archived and is not being maintained.

Stream.Position Property

When overridden in a derived class, gets or sets the position within the current stream.

[Visual Basic]
Public MustOverride Property Position As Long
public abstract long Position {get; set;}
public: __property virtual __int64 get_Position() = 0;
public: __property virtual void set_Position(__int64) = 0;
public abstract function get Position() : long;
public abstract function set Position(long);

Property Value

The current position within the stream.


Exception Type Condition
IOException An I/O error occurs.
NotSupportedException The stream does not support seeking.
ObjectDisposedException Methods were called after the stream was closed.


For an example of creating a file and writing text to a file, see Writing Text to a File. For an example of reading text from a file, see Reading Text from a File. For an example of reading from and writing to a binary file, see Reading and Writing to a Newly Created Data File.

The stream must support seeking to get or set the position. Use the CanSeek property to determine whether the stream supports seeking.

Seeking to any location beyond the length of the stream is supported.

The Position property does not keep track of the number of bytes from the stream that have been consumed, skipped, or both.



Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Stream Class | Stream Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File