// To save the text as one string use 'ReadAllText()'
string text = System.IO.File.ReadAllText(@"C:filepathfile.txt");
// To save each line seperately in an array use 'ReadAllLines()'
string[] lines = System.IO.File.ReadAllLines(@"C:filepathfile.txt");
// Example #1
// Read the file as one string.
string text = System.IO.File.ReadAllText(@"C:UsersPublicTestFolderWriteText.txt");
// Example #2
// Read each line of the file into a string array. Each element
// of the array is one line of the file.
string[] lines = System.IO.File.ReadAllLines(@"C:UsersPublicTestFolderWriteLines2.txt");
string[] text = System.IO.File.ReadAllLines(@"C:usersusernamefilepathfile.txt");
var text = File.ReadAllText(file, Encoding.GetEncoding(codePage));
List of codepages : https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers?redirectedfrom=MSDN