Stream Programming with .NET
A stream is a set of data flowing from a source or a sink.
A stream may concerne not also files but equally data transfer on the network or in memory.
Under .NET, the Input/Output operations are essentially managed by the abstract class Stream.
Being an abstract class, it's impossible to instanciate it directly. It's primary goal is to allow a standardized way of performing I/O operations.
A number of classes deriving from Stream exists, these may be splitted in two categories.
The first category contains all classes implementing the Stream class for a specific I/O operation. These classes are:
- FileStream, to work with files;
- NetworkStream, for networked data transfer;
- MemoryStream, for memory exchange;
The second category contains classes deriving from Stream but enhancing what a Stream has to offer. They may be considered as a layer over the base functionality offerd by the Stream class.
This category contains the following classes:
- BufferedStream, which allow to perform buffered operation over a Stream. Due to the fact that datas are not directly written to the stream, the number of I/O needed to perform the operation decrease, thus increasing the execution of the operation;
- CryptoStream, which allow the data written or read from the stream to be encrypted or decrypted.
The following drawing summarize the stream classes hierarchy:
If you want, you can continue to: