Answers for "c sharp how to read a text file"

C#
25

c sharp how to read a text file

// To save the text as one string use 'ReadAllText()'
string text = System.IO.File.ReadAllText(@"C:\filepath\file.txt");
// To save each line seperately in an array use 'ReadAllLines()'
string[] lines = System.IO.File.ReadAllLines(@"C:\filepath\file.txt");
Posted by: Guest on February-22-2020
2

how to read a text file C#

string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");
Posted by: Guest on October-06-2020

C# Answers by Framework

Browse Popular Code Answers by Language