Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   VCL (http://www.delphipages.com/forum/forumdisplay.php?f=4)
-   -   How to get file size to fileread? (http://www.delphipages.com/forum/showthread.php?t=217802)

oxygen 09-16-2018 03:54 PM

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.

oxygen 09-16-2018 04:38 PM

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 );



All times are GMT. The time now is 08:16 PM.

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