Working with Streams

Streams are classes that specialize in data transfer. You use them to read and write data to and from files, networks, memory, strings, and the Internet. Here's an overview of the common stream classes in C#:

  • Stream— Abstract class for working with bytes in streams; the base class for streams.

  • BinaryReader/BinaryWriter— Reads and writes data in binary format.

  • BufferedStream— Adds buffering to another stream.

  • MemoryStream— Works with data in memory directly.

  • FileStream— Reads and writes files. Supports synchronous and asynchronous random access to files.

  • TextReader/TextWriter— Abstract text reader and writer classes that use Unicode.

  • StringReader/StringWriter— Reads from and writes to text strings using streams.

  • NetworkStream ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.