O'Reilly logo

.NET Programming: A Practical Guide Using C# by Pradeep Tapadiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streams

A common programming task is to read data from or write data to files, network sockets, or some other devices. The BCL formalizes this behavior by means of an abstract class Stream (namespace System.IO). Table 5.2 shows some frequently used methods available on this class.

Table 5.2. Some Methods Available on System.IO.Stream
MethodDescription
CanSeekCan you seek to a position within the stream?
CanReadCan the stream be read?
CanWriteCan the stream be written to?
LengthLength of the stream.
PositionCurrent cursor position.
SeekSeek to a position.
ReadRead bytes from the stream.
WriteWrite bytes to the stream.
FlushFlush any buffered data to the underlying device.
CloseClose the stream and release any resources (such as sockets and file handles). ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required