GetFile

GetFile retrieves a file from the remote machine. The file is then stored locally.

Syntax

GetFile(STRING remotefile, String localfile)

Where:

  • RemoteFile is a string (example: readme.txt)
  • LocalFile is a string (example: readmecopy.txt)
Returns

Boolean. If it returns TRUE, the function has succeeded, otherwise it means that and error was returned. When FALSE is returned, FTPObject.LastError will return the WIN32 error code.

Example

An example of GetFile function in the FTPA protocol used to transfer files between network computers. Object. Retrieves all files found in the root of the FTP server:

Function Main

Dim FTPobj as Object

Const DIRECTORYMASK=&H10

ip = "127.0.0.1"

port = 21

cr = Chr(13) + Chr(10)

Set FTPobj = FTP.Connect (ip,port,TRUE,"anonymous","lnss@gfi.com")

Found=FTPobj.FindFirstFile("*")

While Found

If (FTPobj.GetFindFileAttributes And DIRECTORYMASK) = DIRECTORYMASK Then

FileType="directory"

Else

FileType="file"

ret = FTPobj.GetFile (FTPobj.GetFindFileName, FTPobj.GetFindFileName)

End If

echo "File: " + FTPobj.GetFindFileName + " size: " + CStr(FTPobj.GetFindFileSize) + " bytes type: " + FileType & cr

Found=FTPobj.FindNextFile

Wend

End Function