Here is the listing of C# programming examples on Files.
1. C# Examples on Files and Directories
A file is a collection of data and information and a Directory is a location in the computer where files are stored. The programs in the given section creates a file, reads the contents of a file, creates a directory, views the information of the file, views the date and time of access of a file and checks the existence of a file.
2. C# Examples demonstrating StringReader and StringBuilder
The StringReader class turns an ordinary string into a reader. The StringBuilder class is used to create mutable string. It is same as string class except that it is mutable. The programs in the section demonstrate StringReader and StringBuilder functions. The remaining programs in the section perform text operations in a file, search directories and list files, copies the contents from one file to another file and reads lines from a file until the end of file is reached.
3. C# Examples demonstrating StringWriter, StreamReader and Memory Stream
StringWriter writes to a string synchronously or asynchronously. It is found in the System.IO namespace. The FileInfo class provides instance methods for the creation, copying, deletion, moving, and opening of files. The MemoryStream creates a stream whose backing store is memory. The programs in the following section lists Disk Drives, Illustrates StringWriter, uses StreamReader to read entire line, get file time using file class, read data from stream and cast data to chars, illustrates memory stream class and methods of FileInfo Class.
4. C# Examples implementing Binary Reader and other File Functions
Binary Reader reads the number of bytes from the current stream into a array and advances the current position by number of bytes that are read. The following section contains programs which get content from a file and reads the content 1 byte at a time, lists the files in a directory, calculates the size of a Folder, implements BinaryReader and performs file comparison.