Click or drag to resize

CFtp.GetFile Method

X#
Receive a file from the FTP server.

Namespace:  VO
Assembly:  VOInternetClasses (in VOInternetClasses.dll) Version: 2.21
Syntax
 VIRTUAL METHOD GetFile(
	cRemoteFile,
	cNewFile,
	lFailIfExists,
	nFlags
) AS USUAL CLIPPER
Request Example View Source

Parameters

cRemoteFile (Optional)
Type: Usual
Name of the remote file that has to be received.
cNewFile (Optional)
Type: Usual
String that contains the name of the file to create on the local system. If not specified, cRemoteFile automatically becomes the name of the local file.
lFailIfExists (Optional)
Type: Usual
Logical value indicating whether the method should proceed if a local file of the specified name already exists. If lFailIfExists is TRUE and the local file exists, the GetFile() method fails.
nFlags (Optional)
Type: Usual
Flags that control how the function will handle the file download. The first set of flag values indicates the conditions under which the transfer occurs. These transfer type flags can be used in combination with the second set of flags that control caching. The application can select one of these transfer type values: The following flags handle how the caching of this file will be handled. Any combination of the following flags can be used with the transfer type flag. The possible values are:

Return Value

Type: Usual
TRUE if successful; otherwise, FALSE.
Remarks
This method retrieves a file from an FTP server and stores it under the specified name as a local file.
Examples
The following receives the comprehensive list (00index.txt) of all files contained in the X# download section at ftp.cai.com:
X#
 1FUNC TestGetFile()
 2LOCAL oFTP  AS CFtp
 3LOCAL cFile AS STRING
 4oFTP := CFtp{"VO Sample FTP Agent"}
 5IF oFTP:ConnectRemote("ftp.cai.com", ;
 6                     "anonymous",   ;
 7                     "Darth.Vader@starwars.com")
 8cFile := "00index.txt"
 9IF oFTP:SetCurDir("/pub/vo")
10IF oFTP:GetFile(cFile)
11IF File(cFile)
12? "File received: " + FPathName()
13ENDIF
14ELSE
15__RaiseFTPError(oFTP)
16ENDIF
17ELSE
18__RaiseFTPError(oFTP)
19ENDIF
20ENDIF
21oFTP:CloseRemote()
22RETURN
23STATIC FUNC __RaiseFTPError (oFTP AS CFtp) AS INT ;
24PASCAL
25LOCAL cError    AS STRING
26LOCAL nRet      AS INT
27nRet := oFTP:Error
28IF nRet > 0
29cError := oFTP:ErrorMsg
30IF SLen(cError) > 0
31MessageBox(0, cError, "FTP Error", MB_OK)
32ENDIF
33ENDIF
34RETURN nRet
See Also