To może być trudne, a dlaczego nie możesz odczytać cały plik, parsować linia po linii i odczytać tylko to co Ci jest potrzebne?
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Program.cs" company="4programmers.net">
// mr-owl, 4programmers.net, All Right Reserved
// </copyright>
// <summary>
// Defines the Program type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ConsoleApplicationParseLargeFile
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
var fileName = "largeFile.csv";
var items = GetData(fileName).ToArray();
}
private static IEnumerable<string> GetData(string fileName)
{
var arrayLength = 10;
var myItemIndex = 1;
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
using (var sr = new StreamReader(fs, Encoding.Default))
{
while (sr.Peek() > -1)
{
var line = sr.ReadLine();
if (string.IsNullOrEmpty(line))
{
continue;
}
var array = line.Split(new[] { ',' });
if (array.Length == arrayLength)
{
var item = array[myItemIndex];
yield return item;
}
}
}
}
}
}
}
mr-owl