Delphi Check File Size

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; 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. Gajic, Zarko. 'File Size - Get the Size of a File in Bytes using Delphi.' ThoughtCo, Mar.
Jun 20, 2012 Get a file size in Delphi. I downloaded some code from the internet that will allow me to get a file size. Check this link which shows and. All about Borland Delphi. Programming tips, downloads. Find the size of a file? For some reason both methods of finding file size return. Thread: Delphi reduce exe size. This only shows that Delphi in file size very bad. Compile and check the size. Get File Size Get File. I just can't figure out how to get the file size. I've tried searching around in Delphi. The Tek-Tips staff will check this out and.
27, 2017, thoughtco.com/file-size-in-bytes-using-delphi-1057888. Gajic, Zarko. (2017, March 27). File Size - Get the Size of a File in Bytes using Delphi. Retrieved from Gajic, Zarko.
'File Size - Get the Size of a File in Bytes using Delphi.' (accessed February 28, 2018).
Quote Mehrzad Abdollahi wrote: >Hi, >I am trying to check whether a text file is empty or not. There is a >function in TP which is called 'FileSize' that can be used to get the >size of the file in byte. Unfortunalety this function cannot be used >for text file. Does anybody know a way of writing similar function for >text files. >Regards >M.
Abdollahi Assuming the file exists: function IsFileEmpty(var FileName: string): bool; var f: file; begin AssignFile(f, FileName); Reset(f, 1); if FileSize(f) = 0 then IsFileEmpty:= true else IsFileEmpty:= false; Close(f); end; Joe -- Joe C. Hecht Join the Delphi Online Discussion Forum at http://www.borland.com/techsupport/delphi/.
Quote >Mehrzad Abdollahi wrote: >>Hi, >>I am trying to check whether a text file is empty or not. Microsoft Intellimouse Driver Os X. There is a >>function in TP which is called 'FileSize' that can be used to get the >>size of the file in byte.
Unfortunalety this function cannot be used >>for text file. Does anybody know a way of writing similar function for >>text files. >>Regards >>M. Abdollahi >Assuming the file exists: >function IsFileEmpty(var FileName: string): bool; >var >f: file; >begin >AssignFile(f, FileName); >Reset(f, 1); >if FileSize(f) = 0 then >IsFileEmpty:= true else >IsFileEmpty:= false; >Close(f); >end; >Joe >-- >Joe C. Hecht >Join the Delphi Online Discussion Forum at >Better use FindFirst! Quote >function IsFileEmpty(var FileName: string): bool; >var >f: file; >begin >AssignFile(f, FileName); >Reset(f, 1); >if FileSize(f) = 0 then >IsFileEmpty:= true else >IsFileEmpty:= false; >Close(f); >end; Doesn't compile (bool & AssignFile) - is it Delphi? In BP7 real mode, ' IsFileEmpty:= FileSize(f) = 0; ' gives shorter code and is IMHO more readable.
-- John Stockton, Surrey, UK. J.@merlyn.demon.co.uk Turnpike v1.12 MIME. Web URL: -- includes FAQqish topics and links. Correct 4-line sig separator is as above, a line comprising '-- ' (SoRFC1036) Before a reply, quote with '>' / '>', known to good news readers (SoRFC1036). Quote wrote: >Hi, >I am trying to check whether a text file is empty or not. There is a >function in TP which is called 'FileSize' that can be used to get the >size of the file in byte. Unfortunalety this function cannot be used >for text file.
Does anybody know a way of writing similar function for >text files. Abdollahi See especially the last paragraph. Open the file in a manner acceptable for FileSize.; alternatively, use FindFirst. -- John Stockton, Surrey, UK. J.@merlyn.demon.co.uk Turnpike v1.12 MIME. Web URL: -- includes FAQqish topics and links. Correct 4-line sig separator is as above, a line comprising '-- ' (SoRFC1036) Before a reply, quote with '>' / '>', known to good news readers (SoRFC1036).