moveFile()

Moves the specified file or directory to the target directory.

Synopsis

moveFile(string from, string to);

Parameters

Parameter Meaning
from File and path (e.g. "c://test1//test.txt") or directory and path (e.g. "c://test1"). You can specify an absolute path or a relative path from the PROJ_PATH directory. NOTE: An empty string "" is interpreted as PROJ_DIR.
to

If you want to move a file, the parameter to can be defined as follows:

  • Path of an existing directory. In this case the file is moved to the directory with its original name. If there is already a file with the same name in this specific directory, the file cannot be moved!

  • Path of an existing directory + a file name which is not used. The file will be moved to the directory with the defined name.

If a directory should be moved, define a path of an existing directory + a sub directory (the name must not exist in the target directory).

Return value

If the function was executed successfully it returns TRUE, otherwise FALSE. If the function returns FALSE, an error message is issued in case of, e.g., a source or target file does not exist, missing permissions for a source or a target file, parts of the target path are missing or file system border violation.

Example:

WCCOAui (1), 2020.10.08 09:34:02.995, CTRL, WARNING, 54, Unexpected state,

Module: _QuickTest_

Panel: C:\moveFileProj\panels\test.pnl [test.pnl]

Object: 0 named: "PUSH_BUTTON1" of type: PUSH_BUTTON

Script: Clicked

Line: 9, moveFile("C:/moveFileProj/invalidDir/invalidFile", "C:/moveFileProj/log/anyFile") The source file does not

exist.

Error

-

Description

Moves the specified file or directory to the target directory.

Example

main()
{
  moveFile("D://source//1.txt","D://target");
//moves "1.txt" to the new directory
  moveFile("D://source//a.txt","D://target//b.txt");
//moves "a.txt" to the new directory, new name is "b.txt"
  moveFile("D://source//sub", "D://target//sub_new");
//moves the directory "sub" to the new directory, new name is "sub_new"
}

Assignment

File functions

Availability

CTRL