Created
March 14, 2014 13:40
-
-
Save welkson/9547824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TxtFileRecCount(const Filename: string): integer; | |
var | |
FS : TFileStream; | |
buffer : string; | |
red, i : integer; | |
begin | |
result := 0; | |
if FileExists(Filename) then begin | |
SetLength(buffer, $FFFF); | |
FS := TFileStream.Create(Filename, fmOpenRead or fmShareDenyNone); | |
try | |
red := FS.Read(buffer[1], $FFFF); | |
while red > 0 do begin | |
if red < $FFFF then | |
SetLength(buffer, red); | |
for i := 1 to red do | |
if buffer[i] = #10 then | |
Inc(result); | |
if red = $FFFF then | |
red := FS.Read(buffer[1], $FFFF) | |
else | |
red := 0; | |
end; | |
finally | |
FS.Free; | |
end; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment