File Size - Get the Size of a File in Bytes using Delphi
Monday November 10, 2008
in Delphi TIPS :: When working with files and folders from a Delphi application you sometimes need to know what is the size of a file (in bytes).
Read the full article to learn how to File Size - Get the Size of a File in Bytes using Delphi
Related:


Comments
Hi,
two comments on this function:
1) Filesize already exists in the System library
2) FindClose(sr) does not compile at least in Delphi 2007 as it expects a handle
Hi,
two comments on the Filesize function:
1) The function “Filesize” exists already in the “system” library
2) Findclose(sr) does not compile at least in Delphi 2007, as it expects a handle instead of a Tsearchrec
regards,
Stefan
OK, I got it:
SysUtils.FindClose(sr);
does the trick.
Stefan,
system.FileSize does not work well with files > 2GB.
var
f : File of byte;
fs : cardinal;
begin
AssignFile(f,’2gbfile.zip’);
try
Reset(f);
fs := system.FileSize(f);
finally
CloseFile(f);
end;
end;
the above code would return minus value for a 2+ gb file.
Zarko, I just wanted to point out that a function with the same name already exists, so “GetFilesize” would be better and furthermore there are several Findclose functions defined in system and sysutils with different parameters. Choosing the correct namespace will call the correct one.
Stefan
ZARKO:
Sorry about my english, but…let try ask you a important question for me…
I’m trying to get the Mozilla firefox 3.0 adress bar by it’s class name… I’m going to be crazy!! ’cause I tryed everything..
In I.E (everything gone be all rigth!!!).
I use the program “Windowse” for this purposes.
I realy need a “BRAIN” to help me a solve this big problem.
I’m from Brazil and here, programmers watches your blog and
really loves it…(’cause there are important articles)
ok, sorry about my poor english and…PLEASE:
Someone heeeelppp-mee with this code!!!
Thanks for all…