The FTPGetFile function downloads the specified file(s) from the FTP server.
Used to automate the download of files from a FTP server such as reports, images, etc.
ret=FTPGetFile(<spec_files>,<local_foldername> [,Ascii|Binary [,<local_filename>])
<spec_files>, string, name of the file(s) to download. Wildcards (* or ?) may be used to download files matching a certain mask.
<local_foldername>, string, destination folder name for the downloaded file(s). If the folder does not exist, it is automatically created at execution.
ASCII or BINARY, optional keyword. The default is BINARY. Specify ASCII if you download text files and want to use Ascii.
<local_filename>, optional string, ndestination file name for the downloaded file if only one file is downloaded. If this parameter is not specified or if multiple files are downloaded (and in this last case, even if <local_filename> is specified), the filenames on the local PC are the same as on the FTP server. If <local_filename> includes by mistake a path, the path is not considered and the file is written in <local_foldername>.
Ret, optional numeric return value. If the function succeeds downloading the file(s) within 30 seconds, the function returns 0. INCREASE the timeout using #FTPTimeout if the download takes more than 30 seconds. If the function fails, the return value is a nonzero negative value (see FTP Functions Error Codes).
When files are transferred in ASCII mode, the transferred data is considered to contain only ASCII formatted text. The party that is receiving the transferred data is responsible for translating the format of the received text to one that is compatible with their operating system. The most common example of how this is applied pertains to the way Windows and UNIX handle newlines. On a Windows computer, pressing the "enter" key inserts two characters in an ASCII text document - a carriage return (which places the cursor at the beginning of the line) and a line feed (which places the cursor on the line below the current one). On UNIX systems, only a line feed is used. ASCII text formatted for use on UNIX systems does not display properly when viewed on a Windows system and vice versa.
Binary mode refers to transferring files as a binary stream of data. Where ASCII mode may use special control characters to format data, binary mode transmits the raw bytes of the file being transferred. In this way, the file is transferred in its exact original form.