Zest.

C#: Read a file

A short, tested C# example for read a file. Copy it and adjust the names and paths for your project.

C#
string text = File.ReadAllText("data.txt");
foreach (var line in File.ReadLines("data.txt"))
    Console.WriteLine(line);

Find it in Zest

Search for “csharp read a file” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More C# examples

All C# examples