Sergei Stenkov asked:
> I need to get the number of lines/records in a text file
<snip>
> I wonder if there is a more efficient way of doing the same?
The fastest way that I can think of is to map the file into memory using
the Win32 memory mapped file API, and then walking the memory counting
line terminations. There are a couple of memory mapped file components
available in the Delphi Super page, and the API's are very easy to work
with without them.
We have wrapped the API up and presented things as a stream decendant and
this works nicely for high speed data importing. Biggest file I have
tested with was 10MB worth of stock item data, and that only took about
three and four seconds to walk.
Cheers, Max.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"