Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP Function to determine file size.

Usefull Functions & Procedures

VFP Function to determine file size.

by  EzLogic  Posted    (Edited  )
* Example of use:
* nSize = GetFileSize("C:\SomeFile.Ext")
* Returns:
* -2 if the file name is not passed
* -1 if the file passed as param was not found
* FileSize in Bytes

*********************
FUNCTION GetFileSize
PARAMETERS gcFileName && File to be checked
PRIVATE pnHandle,pnSize
IF PARAMETERS( ) = 0
RETURN -2 && Return -2 if no parameter passed
ELSE
IF !FILE(gcFileName)
RETURN -1 && Return -1 if file does not exist
ENDIF
ENDIF
pnHandle = FOPEN(gcFileName) && Open file
pnSize = FSEEK(pnHandle,0,2) && Determine file size, assign to pnSize
=FCLOSE(pnHandle) && Close file
RETURN pnSize && Return value

*********
Another way of doing it (Thanks for Baltman for the tip)
** I haven't tested it, I assume he had
?SizeArray(adir(SizeArray,"C:\SomeFile.Ext")+1)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top