Free mag vol1 | Page 830

CHAPTER 20  FILE I/O AND OBJECT SERIALIZATION  Source Code You can find the StringReaderWriterApp under the Chapter 20 subdirectory. Working with BinaryWriters and BinaryReaders The final writer/reader sets you will examine in this section are BinaryReader and BinaryWriter. Both derive directly from System.Object. These types allow you to read and write discrete data types to an underlying stream in a compact binary format. The BinaryWriter class defines a highly overloaded Write() method to place a data type in the underlying stream. In addition to the Write() member, BinaryWriter provides additional members that allow you to get or set the Stream-derived type; it also offers support for random access to the data (see Table 20-10). Table 20-10. BinaryWriter Core Members Member Meaning in Life BaseStream This read-only property provides access to the underlying stream used with the BinaryWriter object. Close() This method closes the binary stream. Flush() This me