How do I read/input data in .NET 3.5?

I'm used to .NET 4.0, but came across a situation where I have to revert to .NET 3.5.

In my 4.0 code I would rely on this to read my data:

var Data = File.ReadLines(FilePath).Select(line => line.Split('\t')).ToArray();

The above won't work in 3.5. Does anyone know what is the equivalent in 3.5 that will allow me to read the data at 'FilePath' and put the data into an array?

The error I get in 3.5 is System.IO.File does not contain a definition for ReadLines. This error does not appear when I change my project properties to a target framework of 4.0. It reappears when I use target framework 3.5.

Jon Skeet
people
quotationmark

Well you can use File.ReadAllLines instead - that will read the whole file into a string[] rather than reading it line by line, but you're reading the whole thing into memory anyway due to the ToArray call, so it's just a bit less efficient than with File.ReadLines.

people

See more on this question at Stackoverflow