![]() When you are done reading and writing the file, you should Close the Reader or Writer object. When you create a Reader or Writer object, you pass it either an open FileStream or a filename and let it create the FileStream for you. The StreamReader and StreamWriter classes are character-oriented classes that read and write text files the BinaryReader and BinaryWriter read and write binary streams. ![]() There are blocking and asynchronous methods to read and write individual bytes or byte arrays, but usually you will use a FileStream through a Reader or Writer object. Similarly, the FileInfo class has an Exists property and a Delete method as well as various Open overloads that all return a new FileStream.īy itself, the FileStream only offers byte-by-byte access to a file. It also has static methods like Open that return a new FileStream object a FileStream object represents an open file. ![]() The File class has static methods like Exists and Delete that do exactly what you'd expect. Reading and writing text and binary files
0 Comments
Leave a Reply. |