Luck
8
Q:

read file c#

// 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");
17
using (StreamReader streamReader = new StreamReader(path_name, Encoding.UTF8))
{
  contents = streamReader.ReadToEnd();
}
6
string[] text = System.IO.File.ReadAllLines(@"C:\users\username\filepath\file.txt");
0
string text = File.ReadAllText(@"c:\file.txt", Encoding.UTF8);
0

New to Communities?

Join the community