GetFTPDirectoryArray Method
Class: FTP_SERVICE
This method retrieves a list of files from the current directory on the FTP Server. The files are placed in an array with each row being a file and that file's information. The array is created from a variable that is passed by reference to the function. So when the function returns, the Files variable contains an array of files.

Not all the array elements may be filled in, depending on the type operating system the FTP Server is running on. For example, if the FTP Server is running on NT Server, long file names are supported.

Note
After the function returns, doing an EMPTY(laDirectory) will return .T. if no files were found in the directory on the FTP Server.
Note
This method doesn't support multioperations - FTP_SERVICE::lMultiOperations.
=
Object.GetFTPDirectoryArray
Parameter
laDirectory
Array of files
Type Array
By reference  
Direction Output
Holds an array of files after the function completes.
The Files array has the following structure:
TypePositionNameDescription
C [x, 1]File nameLong file name if available
C [x, 2]Alternate File nameShort file name if available
N [x, 3]File SizeSize of file in bytes
T [x, 4]File Create DateFile create date and time
T [x, 5]File Last Access TimeLast access date and time
T [x, 6]File Last Write TimeLast write date and time
C [x, 7]File AttributesFile attributes

The file Attributes array index is a string with the following characters concatenated together:
ValueDescription
'R' FILE_ATTRIBUTE_READONLY
'H' FILE_ATTRIBUTE_HIDDEN
'S' FILE_ATTRIBUTE_SYSTEM
'D' FILE_ATTRIBUTE_DIRECTORY
'A' FILE_ATTRIBUTE_ARCHIVE
'N' FILE_ATTRIBUTE_NORMAL
'T' FILE_ATTRIBUTE_TEMPORARY
'C' FILE_ATTRIBUTE_COMPRESSED
'O' FILE_ATTRIBUTE_OFFLINE
lcMask
Mask files
Type Character
Direction Input
Specifies a file mask to filter files in the operation.
Return value Boolean
Returns .T. if the function successfully returned the current directory on the FTP Server. Returns .F. if the function could not get the current directory.
Example
LOCAL loFTP,lii
LOCAL ARRAY laFolders(1)
#INCLUDE "ftp.h"
SET PROCEDURE TO ftp.prg ADDITIVE 
loFTP=CREATEOBJECT('ftp_service') 

IF loFTP.OpenInternet("ABONNE", "PWD", "10.10.10.10", "21")

   IF !loFTP.GetFTPDirectoryArray(@laFoders,"*.txt")
      ?loFTP.GetExtendedErrorCode(),loFTP.GetExtendedErrorMsg()
   ELSE

      FOR lii=1 TO ALEN(laFolders,1)
          ?laFolders[lii, 1         && File name
          ?CHR(9)+"Alternate File name: "+laFolders[lii, 2]
          ?CHR(9)+"File Size: "+laFolders[lii, 3]
          ?CHR(9)+"File Create Date: "+laFolders[lii, 4]
          ?CHR(9)+"File Last Access Time: "+laFolders[lii, 5]
          ?CHR(9)+"File Last Write Time: "+laFolders[lii, 6]
          ?CHR(9)+"File Attributes: "+laFolders[lii, 7]
      NEXT
   ENDIF
   =loFTP.CloseInternet() 
ENDIF
RELEASE PROCEDURE ftp.prg
See also
Expand/Collapse source code of procedure GetFTPDirectoryArray Source Code
      LPARAMETERS OUTREF laDirectory, INP lcMask
      LOCAL cStruct, liResult, lnCount, fResult, lffHandle
      IF This.OpenFTPConnection(This.cStartupFolder)     && Open an FTP Handle
         lcMask = lcMask + cNULL

         * Dimension the array to store the directory
         * [x, 1] = FileName
         * [x, 2] = Alternate FileName
         * [x, 3] = File Size
         * [x, 4] = File Create Date
         * [x, 5] = File Last Access Time
         * [x, 6] = File Last Write Time
         * [x, 7] = File Attributes
         DIMENSION laDirectory [1, 7]
         laDirectory [1, 1] = .F.

         * This is for a FoxPro Quirk.
         lcStruct = SPACE(319)   && Allocate space for the returned structure

         =This.BeforeGetFTPDirectoryArray(@laDirectory, @lcMask)
         * Get the first file or find out if 
         lffHandle = FtpFindFirstFile(This.nConnect_Handle, @lcMask, @lcStruct, 0, 0)
         This.GetExtendedError()

         IF lffHandle = 0 OR This.nResult_Code = ERROR_NO_MORE_FILES
            This.CloseFTPConnection()   && Close FTP Handle
            RETURN .F.
         ENDIF

         * Parse out First File Information
         =This.CrackFile(lcStruct, @laDirectory)

         llResult = 1
         DO WHILE This.nResult_Code != ERROR_NO_MORE_FILES AND llResult != 0
            lcStruct = SPACE(319)
            * Get next files
            liResult = InternetFindNextFile(lffHandle, @lcStruct)
            =This.GetExtendedError()

            * If we got good information, go ahead and parse it
            IF This.nResult_Code != ERROR_NO_MORE_FILES AND llResult != 0
               =This.CrackFile(lcStruct, @laDirectory)
            ENDIF
         ENDDO
         =This.AfterGetFTPDirectoryArray(@laDirectory, @lcMask,liResult)
         =This.CloseFTPConnection()   && Close FTP Handle
      ELSE
         RETURN .F.     && Unable to get FTP Connection    
      ENDIF
      RETURN .T.