Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2018, 03:54 PM
oxygen oxygen is offline
Junior Member
 
Join Date: May 2018
Posts: 8
Question How to get file size to fileread?

I'm diving in this stuff about two hours but cannot find how to get the size of file to be opened by fileread:


Code:
FileHandle : Integer;
fSize: Integer;
begin
      FileHandle := FileOpen('b:\html.txt', fmOpenRead);
      fSize := fileSize(FileHandle);
      FileRead(FileHandle, buffer , fSize );
end;
I need to read the complete file and FileRead seems to be best suitable for me.

I would like to avoid the fileSize function because it has different type then the FileRead input argument no 3.
Reply With Quote
  #2  
Old 09-16-2018, 04:38 PM
oxygen oxygen is offline
Junior Member
 
Join Date: May 2018
Posts: 8
Exclamation solution

I found solution
Code:
      FileHandle := FileOpen('b:\html\' + SubDirs[m] + '\' + FileList[i], fmOpenRead);
      fSize := FileSeek(FileHandle,0,soFromEnd);
      FileSeek(FileHandle,0,soFromBeginning);
      setLength(buffer, fSize);
      FileRead(FileHandle, buffer , fSize );
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.