Instead of loading whole file into memory, you could read and process the file line-by-line.
using (var streamReader = new StreamReader(fileName))
{
string line;
while ((line = streamReader.ReadLine()) != null)
{
// analize line here
// throw it away if it does not match
}
}
[EDIT]
If you need to run complex queries against the data in the file, the right thing to do is to load the data to database and let DBMS to take care of data retrieval and memory management.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…