Reading and Writing Data
Reading
and writin
g data is accomplished with the
Stream class. Remember streams? This is a chapter
about streams.[9]
Stream supports synchronous and asynchronous reads
and writes. The .NET Framework provides a number of classes derived
from Stream, including
FileStream, MemoryStream, and
NetworkStream. In addition, there is a
BufferedStream class, which provides buffered I/O
and which can be used in conjunction with any of the other stream
classes. The principal classes involved with I/O are summarized in
Table 21-5.
Table 21-5. Principle I/O classes of the .NET Framework
|
Class |
Use |
|---|---|
|
|
Abstract class that supports reading and writing bytes. |
|
|
Read and write encoded strings and primitive datatypes to and from streams. |
|
|
Provide implementations for the abstract
|
|
|
For reading to and from |
|
|
|
|
|
A stream that adds buffering to another stream such as a
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access