How about replacing
string[] linesOfData = new string[File.ReadAllLines(filePath).Length];
by
string[] linesOfData = File.ReadAllLines(filePath);
?
The former reads everything without storing it at all, counts the lines, and creates an array with a null for every line; the latter simply returns the lines.
When in doubt, look in the
documentation[
^] (just google
C# ReadAllLines
)