[fpc-devel] Determin file size - how?

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Dec 15 09:29:17 CET 2011

On Thu, 15 Dec 2011, Hans-Peter Diettrich wrote:

> Tomas Hajny schrieb:
>>> I wonder how to obtain the size of an file on disk. The only function I 
>>> could find so far is FileSize, which requires an open File, but nothing 
>>> for an file name :-(
>>> ATM FileSize(TEXT) would help, too, but FileSize only accepts an FILE, not 
>>> TEXT :-(
>> What exactly do you want to achieve?
> Effectively I'm missing a function FileSize(filename), similar to FileExists 
> or FileAge, for general use.
>> Is it because the file may be open as a text and denied sharing wouldn't 
>> allow parallel opening for reading as an untyped file (as suggested by 
>> Vinzent)? If this is the case, there is a nasty but completely platform 
>> independent hack which you could use (based on the fact that the underlying 
>> operating systems and their APIs make no difference between file and text).
> Normally I use TFileStream's, which have a Size property. But I find it nasty 
> to open an file, when I only want to know its size. FPC (like Delphi) lacks 
> some basic file/directory handling functions (Size, Remove, Rename...), at

I think you didn't look very well in the docs.


I agree the filesize is missing.

I will look into adding them to the documentation topics.


More information about the fpc-devel mailing list