WebGetFile
- Last UpdatedOct 29, 2026
- 2 minute read
WebGetFile is a built-in function that gets a file from a specified URL and then saves it locally.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
WebGetFile |
File |
Synchronous |
No |
Supported |
Supported |
Supported |
Supported |
Supported |
Syntax
WebGetFile(strURL,strLocalPath)
strURL
The URL (that is, the web address) of the file you want to get. You can specify a port number as part of the URL.
strLocalPath
The complete local file path where you want to save the downloaded file.
Note: Follow the conventions of the target platform for the file path and name, and separators. For example, a file path in Windows starts with a drive letter and uses backward slashes as separators (C:\path\to\file), while a file path in Linux starts at the root directory and uses forward slashes as separators (/path/to/file).
Return value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
xxx |
HTTP status code; see below. |
|
0 |
Success. |
|
-1 |
Invalid number of parameters. |
|
-2 |
Invalid URL. |
|
-3 |
Invalid port number. |
|
-4 |
Error while opening a connection to the specified server. Make sure the server name (that is, the domain or host name) and port number are correct. |
|
-5 |
Error while saving the file. Make sure the local path is correct and you have the necessary privileges to save files there. |
In some cases, this function might successfully connect to the web server but still fail to get a file from the specified URL. When that happens, the web server should provide a three-digit HTTP status code which indicates the reason for the failure (for example, "404 File Not Found"), and then this function will relay that code as its return value.
If this function continues to return errors, use a web browser on the same computer that hosts the project runtime to confirm it can access the network and go to the specified URL.
Examples
Get the file named myfile.txt:
WebGetFile("http://www.the-internet.com/myfile.txt","C:\myfile.txt")
Get the file specified by the project tag myURL:
WebGetFile(myURL,myFilePath)