[fpc-devel] Determin file size - how?

Tomas Hajny XHajT03 at hajny.biz
Thu Dec 15 00:26:25 CET 2011

On 14 Dec 11, at 22:11, Hans-Peter Diettrich wrote:

> 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? 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).

Or is it because you don't want to open the file at all (e.g. to 
avoid modifying the timestamp of the last file access)? If this is 
the case, you probably need to stick to FindFirst, etc.


More information about the fpc-devel mailing list