Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textfile open -> blockwise

Status
Not open for further replies.

dx111ge

Programmer
Sep 4, 2002
62
EU
Hello,

normally a textfile will be opened line by line , with a large textfile, this takes a long time. I saw some tools, which are faster (1 sec compared to 3-5 min). Maybe this is more a block reading ? I don't know , but thanks for ponting me in the right direction !

Thanks
Sven
 
Hi,

If you want to read the contents of an entire file you would be better off using a TFileStream.

e.g.

Code:
var
  StrBuff: string;
  fsInput: TFileStream;
begin
  fsInput := TFileStream.Create(aFileName, fmOpenRead or fmShareExclusive);
  try
    SetLength(StrBuff, fsInput.Size);
    fsInput.Read(StrBuff[1], fsInput.Size);
  finally
    fsInput.Free;
  end;
end;

The contents of the file will then be held in StrBuff

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top