Getting the last line of a file

I’m trying to get the last line of a file without traversing the whole file. Is there a way to do this? I looked in “Help” and in this forum and didn’t see it.

Also, if anyone knows how to do it using NotesStream class, that would be great (the session at lotusphere said this was much faster but like most I am using to using Line Inputs).

Thanks in advance!

Subject: Getting the last line of a file

You might try the following:

Use NotesStream.Position with a value that is returned by the FileSize minus the expected length of the last line.

Alternatively set Position on a very high value and read the actual position and point a line back.

Subject: RE: Getting the last line of a file

Thanks so much for your response Rob.

I think your second option may be the way to go. I’m looking at the Designer help and I see how to set the position. So if I set it to a really high value, how do I move a line back? Playing with the offset? The size of the file is constantly changing and I’m not positive that the lines will be of the same length so i don’t know if option #1 is possible for this task.

Subject: RE: Getting the last line of a file

What you could do is setting the position back as much as the longest line might be and multiply this by 2.

You could go back 4 times the largest expected line length. Remember it is always quicker to be on the safe side, than having to read the whole file.