Friday, May 15, 2020
Delphi File Size in Bytes
The FileSize function returns the size of a file, in bytes -- a useful result for certain file-handing applications within a Delphi program. Get File Size The FileSize function returns the size of a file in bytes; the function returns -1 if the file was not found. // returns file size in bytes or -1 if not found.function FileSize(fileName : wideString) : Int64;varsr : TSearchRec;beginif FindFirst(fileName, faAnyFile, sr ) 0 thenresult : Int64(sr.FindData.nFileSizeHigh) shl Int64(32) Int64(sr.FindData.nFileSizeLow)elseresult : -1;FindClose(sr);end; When you have the size of a file in bytes, you may wish to format the size for display (Kb, Mb, Gb) to assist your end users in comprehending the data without having to convert units.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment