.NET has several types of streams, each of which is derived from System.IO.Stream:
Provides a buffered stream used to read and write data from files.
Provides a stream that is buffered in memory instead of physical storage. This stream can alleviate the need for temporary buffers and files.
Forward-only stream used to send and receive data through network sockets.
Provides a stream that associates data to cryptographic transformations.
Generally, streams support the following actions:
Reading using Read (synchronous) or BeginRead (asynchronous).
Writing using Write (synchronous) or BeginWrite (asynchronous).
Seeking to determine a position or change a location within the stream using Seek.
Not all streams support every action. NetworkStream, which is used to send and receive data through network sockets, does not support seeking, for example. However, it is easy to determine what capabilities a stream supports by calling CanRead, CanWrite, or CanSeek.
.NET also supports a buffered stream, which is encapsulated by the System.IO.BufferedStream class. A buffered stream contains a backing memory store that acts as a cache for read and write operations. It is most commonly used in conjunction with a NetworkStream, as data is usually read and written in chunks over a socket. The FileStream class already contains internal buffering, and memory ...