Posted By

icebob on 08/02/10


Tagged


Versions (?)

Get file size


 / Published in: Delphi
 

  1. function GetFileSize(const filename: string): Int64;
  2. var
  3. f: TWin32FindData;
  4. h: THandle;
  5. begin
  6. result := -1;
  7. try
  8. if not FileExists(filename) then
  9. exit;
  10. h := FindFirstFile(PChar(filename), f);
  11. if h = INVALID_HANDLE_VALUE then
  12. RaiseLastWin32Error;
  13. try
  14. Result := f.nFileSizeHigh shl 32 + f.nFileSizeLow;
  15. finally
  16. windows.FindClose(h);
  17. end;
  18. except
  19. end;
  20. end;

Report this snippet  

You need to login to post a comment.