|
Summary
Retrieve file from server.
Syntax
| Boolean GetFileWithRestart (LocalFile, RemoteFile, Marker) |
| |
RemoteFile |
String |
| |
LocalFile |
String |
| |
Marker |
String |
Description
This method is used to allow the user to recover from a failed file transfer and to complete the file transfer from the point of failure. For this to happen, this function must be used to
initiate the file transfer as well as to recover from the failure.
The GetFileWithRestart method takes a remote file name (RemoteFile), a local file name (LocalFile) and Marker as its parameters and returns a boolean. A marker is a value
returned by the server to indicate a particular point in the file transfer.
If the file was successfully transferred, then the method returns True; otherwise, it returns False. The application should ensure that the method was successfully executed by checking the return
value. The method also sets the LastResult property. The value of the LastResult property can be checked to determine if any error occurred.
In direct mode, a call to the GetFileWithRestart method transfers the remote file to the local file. The remote file and the local file are passed as parameters to this method. This feature allows an
application to transfer complete files of any size without doing any I/O itself. The local file parameter passed must contain a fully qualified path name since there is no current local directory. .
In direct mode Marker is ignored but user should set RetryCount property before calling this function. RetryCount property controls the number of times Restart command will
be sent to the server in case of abnormal termination of file transfer. Default value of RetryCount is 0.
For an event based file transfer, pass an empty string as the LocalFile parameter. If Marker is not NULL, file is retrieved from this Marker position, user is required to
position the local file corresponding to the marker position before calling this function. When a file is transferred through events, one or more OnReceive and OnReceiveMarker events will be fired.
An OnReceive event delivers a portion of the data from the remote file to the application. An OnReceiveMarker event delivers a marker from the remote server to the application. User is required to
save the current file position and the received server marker. In case user wants to restart the file transfer from the middle, user needs to position the local file to the saved file position and
use GetFileWithRestart function with the corresponding server marker string.
Note:
When doing recovery in an event based transfer it is the responsibility of the application to know the corresponding byte position of the block of data immediately before the last marker was
received for the local file.
Example
Result = FTPClient.GetFileWithRestart ("c:\test.exe", "test.exe", "") If Result = False Then MsgBox "Cannot get file from server", 64, "Sample Program"
End If
|