FTPGet
- Last UpdatedOct 29, 2026
- 2 minute read
FTPGet is a built-in function that gets a file from an FTP server and then saves it on the local computer.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
FTPGet |
FTP |
Asynchronous |
No |
Supported |
Supported |
Not supported |
Supported (see Notes below) |
Not supported |
Syntax
FTPGet(strRemoteFile, strLocalFile, optNumTransferType, optNumOverwrite)
strRemoteFile
The full path and name of the file that you want to get from the FTP server, using the syntax "/folder/filename.extension". Some FTP servers are case sensitive, so you should always use correct capitalization.
strLocalFile
The full path and name where you want to save the file on the local machine, using the syntax "C:\folder\filename.extension".
optNumTransferType
A numerical flag that specifies the type of file transfer:
|
Value |
Description |
|---|---|
|
0 |
Unknown (default). |
|
1 |
ASCII. |
|
2 |
Binary. |
|
10 |
Unknown, without caching. |
|
11 |
ASCII, without caching. |
|
12 |
Binary, without caching. |
This parameter is optional; if no value is specified, the transfer type is unknown (0) by default.
optNumOverwrite
A numeric flag that specifies whether the local file (specified by strLocalFile) may be overwritten if it already exists:
|
Value |
Description |
|---|---|
|
0 |
Do not overwrite (default) — return an error if the file already exists. |
|
1 |
Overwrite. |
This parameter is optional; if no value is specified, the default value is 0.
Returned value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
-9 |
Transfer pending. (A previous FTP transfer is still being executed.) |
|
-5 |
Invalid transfer type. |
|
-4 |
Invalid local file. |
|
-3 |
Invalid remote file. |
|
-2 |
Unknown system error. |
|
-1 |
Invalid number of parameters. |
|
0 |
Success. |
|
1 |
Failed to create FTP thread or open connection to the server. |
|
15 |
Data Protection is enabled (see Notes below). |
Notes
This function requires a configured FTP connection, either using the FTP Settings dialog box or from calling the CnfFTP function.
This function is executed asynchronously, so if you want to confirm that the transfer is complete, call FTPStatus.
This function cannot be executed on thin clients (in the Viewer module) when Data Protection is enabled. It must be executed on the project runtime server. For more information, see Enable Data Protection to encrypt sensitive information.
Examples
Get the file 040303.txt from the previously specified FTP server, and then save it at C:\Report.txt:
FTPGet("/Reports/040303.txt","C:\Report.txt")