- , . - , , (numBytes):
cmdLogReader = new System.IO.StreamReader(cmdLogFileIn);
if (cmdLogReader.BaseStream.Length < (numBytes - 1)) {
return cmdLogReader.ReadToEnd;
} else {
cmdLogReader.BaseStream.Seek(-numBytes, System.IO.SeekOrigin.End);
cmdLogReader.ReadLine();
return cmdLogReader.ReadToEnd;
}
BaseStream.Length , , ( : numBytes BaseStream.Length - previousBaseStreamLength - ), , .
You may have to skip the call ReadLineif you do this, since it is really only there to go to the nearest line after returning a random amount. If you know that you are going to land at the boundary of the line, you can simply ReadToEnd.
This is a bit complicated implementation, but very fast, which is why I use it.
J ... source
share