The File and StreamReader Classes

The Directory class offers a lot to developers. Now that we’ve covered that, we’ll move on to another important class. The File class aids in the creation of FileStream objects and provides routines for the creation, copying, deletion, moving, and opening of files.

The StreamReader class implements a TextReader that reads characters from a byte stream in a particular encoding. StreamReader is designed for character input in a particular encoding, whereas the Stream class is designed for byte input and output.

StreamReader defaults to UTF-8 encoding, rather than the ANSI code page for the current system, unless specified otherwise. UTF-8 handles Unicode characters correctly and gives consistent results on localized ...

Get Special Edition Using® Microsoft® ASP.NET 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.