Website development and design blog, tutorials and inspiration

Delphi Get File Size

Get File Size in Delphi

Written By on in Software Engineering 0

Delphi Get File Size

37 words, estimated reading time 1 minutes.

This procedure will get the file size, in bytes, of a specified filename.

  1. function GetFileSize( FileName:string ): int64;
  2. var
  3. fh: integer;
  4. fi: TByHandleFileInformation;
  5. begin
  6. result := 0;
  7. fh := fileopen( FileName, fmOpenRead );
  8. try
  9. if GetFileInformationByHandle( fh, fi ) then
  10. begin
  11. result := fi.nFileSizeHigh;
  12. result := result shr 32 + fi.nFileSizeLow;
  13. end;
  14. finally
  15. fileclose( fh );
  16. end;
  17. end;

Last updated on: Saturday 24th June 2017

Did you Like this Post? Why not Like us on Facebook?

 

Comments

There are no comments for this post. Be the first!

Leave a Reply

Your email address will not be published.