15.3. Reading Data from or Writing Data to a File

Now that we've finished introducing exception handling, we're ready to dive into how to read data from or write data to a file using the I/O classes provided by the .NET FCL. We accomplish the I/O functionality in .NET using the concept of data streams. An input stream is opened to a data source (a file, for example), and the input data is pulled into the input stream, where we can read it inside a program. Similarly, we can place data from the program into an output stream, where it can flow (e.g., be written) to an output destination such as a file. When we provide the I/O functionality for the final version of the SRS, we'll be using the FileStream class extensively to read data from or write ...

Get Beginning C# 2008 Objects: From Concept to Code 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.