Length Property
Collapse the table of content
Expand the table of content

Stream.Length Property

When overridden in a derived class, gets the length in bytes of the stream.

[Visual Basic]
Public MustOverride ReadOnly Property Length As Long
public abstract long Length {get;}
public: __property virtual __int64 get_Length() = 0;
public abstract function get Length() : long;

Property Value

A long value representing the length of the stream in bytes.


Exception Type Condition
NotSupportedException A class derived from 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.


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

© 2015 Microsoft