Move Method

Applies to TestComplete 14.92, last modified on September 16, 2021

Description

Use the Move method to move the file, which corresponds to the given aqFileInfoObj object, to a new location.

Declaration

aqFileInfoObj.Move(PathToNewFile, RenameOnCollision)

aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object
PathToNewFile [in]    Required    String    
RenameOnCollision [in]    Optional    Boolean Default value: True   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

PathToNewFile

Specifies the destination path. It can be either the name of the destination file to create, or the path to the folder where the source file should be moved. Both fully-qualified and relative paths are acceptable. If PathToNewFile is a folder path, it must include a trailing backslash (you can add it to the path using the aqFileSystem.IncludeTrailingBackSlash method).

If the destination folder does not exist, it will be created.

RenameOnCollision

Specifies the method behavior in case the destination folder already contains a file with the specified name.

If RenameOnCollision is True (which is the default value), the method moves the source file to the Copy of <FileName> file in the destination folder. Otherwise, the method overwrites the destination file.

Result Value

True if the file was moved successfully, and False otherwise.

Remarks

If the method fails to move the file, TestComplete will post an information message to the test log explaining the cause of the failure.

Example

The following code moves a file to another folder:

JavaScript, JScript

var fi = aqFileSystem.GetFileInfo("C:\\MyFolder\\MyFile.txt");
fi.Move("C:\\TempFolder\\");

Python

fi = aqFileSystem.GetFileInfo("C:\\MyFolder\\MyFile.txt")
fi.Move("C:\\TempFolder\\")

VBScript

Dim fi

Set fi = aqFileSystem.GetFileInfo("C:\MyFolder\MyFile.txt")
Call fi.Move("C:\TempFolder\")

DelphiScript

var fi;
begin
  fi := aqFileSystem.GetFileInfo('C:\MyFolder\MyFile.txt');
  fi.Move('C:\TempFolder\');
end;

C++Script, C#Script

var fi = aqFileSystem["GetFileInfo"]("C:\\MyFolder\\MyFile.txt");
fi["Move"]("C:\\TempFolder\\");

The following code uses the aqFileInfo.Move method to rename a file:

JavaScript, JScript

var fi = aqFileSystem.GetFileInfo("C:\\MyFolder\\MyFile.txt");
fi.Move("C:\\MyFolder\\NewFile.txt");

Python

fi = aqFileSystem.GetFileInfo("C:\\MyFolder\\MyFile.txt")
fi.Move("C:\\MyFolder\\NewFile.txt")

VBScript

Dim fi

Set fi = aqFileSystem.GetFileInfo("C:\MyFolder\MyFile.txt")
Call fi.Move("C:\MyFolder\NewFile.txt")

DelphiScript

var fi;
begin
  fi := aqFileSystem.GetFileInfo('C:\MyFolder\MyFile.txt');
  fi.Move('C:\MyFolder\NewFile.txt');
end;

C++Script, C#Script

var fi = aqFileSystem["GetFileInfo"]("C:\\MyFolder\\MyFile.txt");
fi["Move"]("C:\\MyFolder\\NewFile.txt");

See Also

Working With Files From Scripts
Copy Method
Rename Method
Move Method
MoveFile Method

Highlight search results