I'm trying to Seek to a Position in a File and want to go with ReadLine after that. FPosition is stored before and matches the beginning of a specific line in the file. Maybe useful: my file has a size of 20gB and is a textfile.
private List<int> FPosition = new List<int>();
(...)
public List<string> LoadFile(string aFile, int aPage, int aRowsPerPage)
{
using (var fileStream = File.OpenRead(aFile))
{
if (FPosition.Count <= (aPage - 1) * aRowsPerPage)
{
fileStream.Seek(FPosition[(aPage - 1) * aRowsPerPage], SeekOrigin.Begin);
}
using (var streamReader = new StreamReader(fileStream,
Encoding.Unicode,
true,
BufferSize))
{
for (int i = 0; aRowsPerPage - 1; i++))
{
myStringList[i] = streamReader.ReadLine;
}
}
}
return myStringList;
}
At which position do I have to do that seek?
Thanks for every help