FileCopy
- Last UpdatedOct 29, 2026
- 2 minute read
FileCopy is a built-in function that copies files from one location to another.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
FileCopy |
File |
Synchronous |
No |
Supported |
Supported |
Supported |
Executed on Server (see Notes below) |
Supported |
Syntax
FileCopy(strSourceFile,strTargetFile,optNumTimeOut)
FileCopy ( strSourceFile , strTargetFile { | ,optNumTimeOut } )
strSourceFile
The file path and name the file(s) to be copied.
This function supports wildcards (* and ?).
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).
strTargetFile
The file path where the file(s) are to be copied.
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).
optNumTimeOut
The timeout (in seconds) for the file copy to be completed.
If the timeout is exceeded, this function returns -1 but it does not cancel the file copy. Instead, it creates an internal process to finish the file copy.
Return value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
-1 |
Timeout exceeded. |
|
0 |
File(s) not copied successfully. |
|
1 |
File(s) copied successfully, within the specified timeout. |
Notes
By default, this function is executed on the project runtime server even when it is called in a screen on a project thin client, which means it only affects directories and files that are located on the server and all paths must be specified in that context. You can change the default behavior to force this function to be executed on the client where it is called, but if you do so, you must keep in mind that the change will affect not just this function but also several other File functions. To change the behavior of these functions, use a text editor to open your project file (<project name>.app) and then edit the following property:
[Options]
ExecuteFileFunctionsOnClient=1
Also, this function is executed synchronously, which means that the project pauses while it waits for the function to return. As such, if the function is called to copy files from or to another volume across a slow network, then the project could be paused for long time.
Examples
Copy all .hst files from the project's history folder to another temporary folder, with a timeout of 1000 seconds:
FileCopy("C:\Studio\Project\Hst\*.hst","C:\Temp\Hst\",1000)