What is the difference between File.ReadAllLines () and File.ReadAllText ()?

What is the difference between File.ReadAllLines() and File.ReadAllText() ?

+51
c # file
Jun 03 2018-10-06T00:
source share
3 answers

ReadAllLines returns an array of strings. Each line contains one line of the file.

ReadAllText returns a single line containing all lines of the file.

+74
Jun 03 2018-10-10T00:
source share

File.ReadAllText () returns a single large string containing the entire contents of the file, while File.ReadAllLines () returns a string array of strings in the file.

Keep in mind that in the case of ReadAllText, "The received row does not contain the final carriage return and / or row feed."

More information is available in the notes section of the File.ReadAllText Method and File.ReadAllLines Method .

+12
Jun 03 2018-10-10T00:
source share

ReadAllText reads all this as a single string, ReadAllLines reads it as a StringArray .

+6
Jun 03 2018-10-10T00:
source share



All Articles