GetFileSize Method
Class: FTP_SERVICE
Description:Get File Size
Get file size.
=
Object.GetFileSize
Parameter
lcFile
Remote file name
Type Character
Direction Input
lnSize
File size
Type Number
By reference  
Direction Input
Return value Boolean
The return value is .T. if getting file size or .F. is not.
Example
LOCAL lnFileSize,lcPath,loFTP #INCLUDE "ftp.h" SET PROCEDURE TO ftp.prg ADDITIVE loFTP=CREATEOBJECT('_myftp') IF loFTP.OpenInternet("anonymous", "gorila@gorila.cz","192.168.2.21", "21") =loFTP.ChangeFTPDirectory("Kubuntu704") * if a method GetFileSize() failed and error message is "550 SIZE not allowed in ASCII mode" * you must uncomment one from next two rows (directly binary mode) *=loFTP.FtpCommand("TYPE I", FTP_TRANSFER_TYPE_BINARY,0,.NULL.) *=loFTP.FtpCommand("BINARY", FTP_TRANSFER_TYPE_BINARY,0,.NULL.) IF loFTP.GetFileSize("test.rar",@lnFileSize) ?lnFileSize ENDIF =loFTP.CloseInternet() ENDIF RELEASE PROCEDURE ftp.prg DEFINE CLASS _myFTP AS FTP_SERVICE PROCEDURE BeforeGetFileSize(lcFile,lnSize) ?PROGRAM(16) ?CHR(9),lcFile,lnSize ENDPROC PROCEDURE AfterGetFileSize(lcFile,lnSize,llRet) ?PROGRAM(16) ?CHR(9),lcFile,lnSize,llRet ENDPROC ENDDEFINE
See also
Expand/Collapse source code of procedure GetFileSize Source Code
      LPARAMETERS INP lcFile, CHNGREF lnSize
      LOCAL lcPom,llRet
      IF This.OpenFTPConnection(This.cCurrentDir)     && Open an FTP Handle
         lcFile = ALLTRIM(m.lcFile)+cNULL
                                
         =This.BeforeGetFileSize(@m.lcFile, m.lnSize)
         *!* FtpGetFileSize does not work as expected for files greater then 4Gb (dwFileSizeHigh always NULL)
         *!* http://groups.google.com.ar/group/microsoft.public.windows.inetexplorer.ie5.programming.wininet/browse_thread/thread/3c118ed4c7c32269/791a868311e60a00?lnk=st&q=ftpfindfirstfile+and+large+files&rnum=2&hl=es#791a868311e60a00

         llRet=This._FTPCommand("SIZE "+m.lcFile,FTP_TRANSFER_TYPE_BINARY,0,.NULL.)
         IF llRet
            lcPom=This.GetExtendedErrorMsg()
            lnSize=VAL(SUBSTR(m.lcPom,AT(" ",m.lcPom)+1))
         ENDIF

         =This.AfterGetFileSize(@m.lcFile,m.lnSize,m.llRet)
         =IIF(This.lMultiOperations,.T.,This.CloseFTPConnection())   && Close FTP Handle
         RETURN m.llRet
      ENDIF
      RETURN .F.