Skip to content

Instantly share code, notes, and snippets.

@wellington1993
Created September 5, 2017 14:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wellington1993/a499bea50996c2e47309af079d452090 to your computer and use it in GitHub Desktop.
Delphi Function FileSize
// returns file size in bytes or -1 if not found.
function FileSize(fileName : wideString) : Int64;
var
sr : TSearchRec;
begin
if FindFirst(fileName, faAnyFile, sr ) = 0 then
result := Int64(sr.FindData.nFileSizeHigh) shl Int64(32) + Int64(sr.FindData.nFileSizeLow)
else
result := -1;
FindClose(sr);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment