#DEFINE MAX_INT 0x100000000 PROTECTED pnFileSize LOCAL ppFileInformation ppFileInformation = REPLICATE(CHR(0), 53) IF GetFileAttributesEx (tcFile, 0, @ppFileInformation) != 0 tcFileSizeHi = SUBSTR( ppFileInformation, 29, 4 ) tcFileSizeLo = SUBSTR( ppFileInformation, 33, 4 ) threadFreeLo = THIS.buf2dword ( tcFileSizeLo ) threadFreeHi = THIS.buf2dword ( tcFileSizeHi ) This.pnFileSize = THIS.getLargeInt( threadFreeLo, threadFreeHi ) ENDIF FUNCTION getFileSize() RETURN This.pnFileSize ENDFUNC PROTECTED FUNCTION getLargeInt (tnlowValue, tnhighValue ) RETURN MAX_INT * tnhighValue + tnlowValue ENDFUNCI call this class by:
loFileAttributes = CreateObject ("fileAttributes", tcFile ) ? "File Size = ", loFileAttributes.getFileSize()The PRG Class Returns: "File Size = 11417657818"
SET CLASSLIB TO ..\classes\mathconversions.vcx This.oMath = CREATEOBJECT( 'mathconversions' ) LOCAL lcFileSizeHi, lcFileSizeLo lcFileInformation = REPLICATE(CHR(0), WIN32_FILE_ATTRIBUTE_DATA_LEN ) && NULL terminated buffer that emulates the WIN32_FILE_ATTRIBUTE_DATA Structure IF GetFileAttributesEx( tcFile, 0, @lcFileInformation ) != 0 lcFileSizeHi = SUBSTR( lcFileInformation, 29, 4 ) lcFileSizeLo = SUBSTR( lcFileInformation, 33, 4 ) lnFileSizeLo = This.oMath.buf2dword( lcFileSizeLo ) lnFileSizeHi = This.oMath.buf2dword( lcFileSizeHi ) lnFileSize = THIS.oMath.getLargeInt( lnFileSizeHi, lnFileSizeLo ) This.pnFileSize = THIS.oMath.getLargeInt( lnFileSizeHi, lnFileSizeLo ) ENDIF getFilesize method: RETURN This.pnFileSizeI call this class by:
SET CLASSLIB TO fileattributes oFile = CREATEOBJECT( 'getfileattributes', 'filename here' ) ?oFile.getFilesize()The VCX Class Returns: 1.2144978777809600E+19