Back to course

Introduction to File I/O

.NET Zero to Hero: Master C# and Modern App Development

Reading and Writing Files

The System.IO namespace contains types that allow reading and writing to files.

Writing:

csharp string text = "Hello Files!"; File.WriteAllText("test.txt", text);

Reading:

csharp string content = File.ReadAllText("test.txt");

File Information:

Use FileInfo to get details like file size or creation time.