1. Computing
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
November 10, 2008 at 8:45 am
(1) Stefan says:

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

November 10, 2008 at 8:47 am
(2) Stefan says:

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

November 10, 2008 at 8:50 am
(3) Stefan says:

OK, I got it:

SysUtils.FindClose(sr);

does the trick.

November 10, 2008 at 9:12 am
(4) Zarko Gajic says:

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.

November 11, 2008 at 8:55 am
(5) Stefan says:

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

November 18, 2008 at 8:18 am
(6) Elton says:

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…

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.