xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

FileSize()

Returns the size of a file.

Syntax

FileSize( [<cFileName>], [<nAttributes>] ) --> nFileSize

Arguments

<cFileName>
This is an optional character string containing the name of the file to query. It defaults to the last file found with FileSeek(). If specified, it must contain a file extension. If <cFileName> contains no drive and/or directory information, the current directory is used. SET DEFAULT and SET PATH settings are ignored.
<nAttributes>
This is a numeric value specifying the file attributes of the files to query. Values of the following list are used for file attributes. To specifiy multiple attributes, pass the sum of the corresponding values:

Values for file attributes
ValueAttribute
0Normal
1Read only
2Hidden
4System
8Volume
16Directory
32Archived

Return

The function returns the size of the specified file in bytes as a numeric value, or -1 in case of an error.

Info

See also:FileAttr(), FileDate(), FileSeek(), FileTime()
Category: CT:DiskUtil , File functions , Low level file functions
Source:ct\files.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example lists file name and size of all PRG files
// in the current directory.

   PROCEDURE Main
      LOCAL cFileName

      cFileName := FileSeek( "*.prg" )

      DO WHILE .NOT. Empty( cFileName )
         ? cFileName, FileSize()
         cFileName := FileSeek()
      ENDDO
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe