GetFile Method  

Copy a file from the server to the local system.


object.GetFile(LocalFile, [RemoteFile], [Offset])


A string that specifies the name of the file that will be created on the local system. The file pathing and name conventions must be that of the local host.
A string that specifies specifies the name of the file on the server. You must have permission to open this file for reading. This is an optional argument; if it is omitted, the value of the Resource property will be used. It is also permissible to specify a complete URL and the file will be downloaded from that location.
An optional integer argument that specifies the byte offset where the file transfer will begin. This argument is only valid for FTP servers, and is used to resume interrupted transfers.

Return Value

A value of zero is returned if the method succeeds. Otherwise, a non-zero error code is returned which indicates the cause of the failure.


The GetFile method copies an existing file from the remote system to the local system. If the local file already exists, it is overwritten.

Not all servers support the ability to restart a file transfer. Notably, a Windows IIS server may return an error if a non-zero restart offset is specified. It is not recommended that you restart text file transfers since differences between end-of-line characters can result in byte offset differences between the local and server system.

If the AppendFile property is true, then the contents of RemoteFile will be appended to the contents of LocalFile, if it exists. Otherwise, the contents of RemoteFile will overwrite the contents of LocalFile.


nError = FileTransfer1.GetFile(strLocalFile, strRemoteFile)
If nError > 0 Then
    MsgBox FileTransfer1.LastErrorString, vbExclamation
    Exit Sub
End If

See Also

AppendFile Property, URL Property, GetData Method, GetMultipleFiles Method, PostFile Method, PutData Method, PutFile Method