Purpose
Gets a file from an FTP server with the given CFtpConnection handle and stores it on the local. machine.
Syntax
MIGetFtpFile( ByVal hConnection As CFtpConnection,
ByVal strRemoteFile As String, ByVal strLocalFile As String,
ByVal bFailIfExists As SmallInt, ByVal dwAttributes As Integer,
ByVal dwFlags As Integer ) As SmallInt
hConnection is a CFtpConnection handle.
strRemoteFile is a string that contains the name of a file to retrieve from the FTP server.
strLocalFile is a string that contains the name of the file to create on the local system.
bFailIfExists indicates whether the file name may already be used by an existing file. If the local file name already exists, and this parameter is TRUE, MIGetFtpFile() fails. Otherwise, MIGetFtpFile() erases the existing copy of the file.
dwAttributes indicates the attributes of the file. This can be any combination of the following FILE_ATTRIBUTE_* flags.
dwAttirbute value | Definition |
---|---|
FILE_ATTRIBUTE_ARCHIVE | The file is an archive file. Applications use this attribute to mark files for backup or removal. |
FILE_ATTRIBUTE_COMPRESSED | The file or directory is compressed. For a file, compression means that all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories. |
FILE_ATTRIBUTE_DIRECTORY | The file is a directory. |
FILE_ATTRIBUTE_NORMAL | The file has no other attributes set. This attribute is valid only if used alone. All other file attributes override FILE_ATTRIBUTE_NORMAL: |
FILE_ATTRIBUTE_HIDDEN | The file is hidden. It is not to be included in an ordinary directory listing. |
FILE_ATTRIBUTE_READONLY | The file is read only. Applications can read the file but cannot write to it or delete it. |
FILE_ATTRIBUTE_SYSTEM | The file is part of, or is used exclusively by, the operating system. |
FILE_ATTRIBUTE_TEMPORARY | The file is being used for temporary storage. Applications should write to the file only if absolutely necessary. Most of the file's data remains in memory without being flushed to the media because the file will soon be deleted. |
dwFlags specifies the conditions under which the transfer occurs. This parameter can be any of the following values:
dwFlags value | Definition |
---|---|
FTP_TRANSFER_TYPE_ASCII | Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents. |
FTP_TRANSFER_TYPE_BINARY | Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method. |
FTP_TRANSFER_TYPE_UNKNOWN | Defaults to FTP_TRANSFER_TYPE_BINARY. |
Return Value
Nonzero if successful; otherwise 0. To determine the cause of the failure, call the MIGetErrorMessage() function.
Description
Both strRemoteFile and strLocalFile can be either partially qualified file names relative to the current directory, or fully qualified. A backslash (\) or forward slash (/) can be used as the directory separator for either name.