I have a read file method that reads the date from the start of the file and then the date at the end of the file. The problem is the file is huge and it takes a long time. Is there way I can read the first line, ignore all but the last and then read the last line?
//Time consuming current method
int counter = 0;
DateTime begDate = new DateTime();
DateTime endDate = new DateTime();
while ((read = s.ReadLine()) != null)
{
if (counter != 0) //skip first line
{
string[] Currentline = read.Split(comma);
DateTime ThisBarsDate = DateTime.ParseExact(Currentline[1] + Currentline[2], "yyyyMMddHHmmss", new CultureInfo("en-US"));
if (counter == 1) begDate = ThisBarsDate;
endDate = ThisBarsDate; //will be correct at end of loop
}
counter++;
}
s.Close();