Get started with file input and output

Beginner
Developer
Higher Education Educator
K-12 Educator
Student
.NET
Visual Studio Code

Learn how to manage local files and directories using the System.IO classes, and how to store and retrieve C# objects using CSV files and the StreamReader and StreamWriter classes.

Learning objectives

  • Describe common file input and output operations, the difference between structured and unstructured data, and common text file formats.

  • Use the Path, Directory, and File classes to create, copy, move, delete, and enumerate local text files and directories.

  • Implement file input and output operations using the StreamReader and StreamWriter classes and CSV files.

  • Control file access using the FileStream class.

  • Read and write binary files using the BinaryReader and BinaryWriter classes.

  • Store and retrieve C# objects using file input and output operations.

Prerequisites

  • An installation of Visual Studio Code with the C# Dev Kit extension installed.

  • The ability to develop object-oriented programs in C# that implement classes, interfaces, class inheritance, and polymorphic behavior.

  • The ability to manage collections, structs, records, generics, dates and times, and anonymous types.