aqFileSystem.CopyFolder Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the CopyFolder method to copy a folder (or a group of folders), including all of its contents, to another location. The method can resolve possible name collisions that may occur while copying folders.

Declaration

aqFileSystem.CopyFolder(Source, Destination, RenameOnCollision)

Source [in]    Required    String    
Destination [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:

Source

The path to the folder to be copied. Both fully-qualified and relative paths are acceptable. This path must not include a trailing backslash (to remove it from the path, you can use the aqFileSystem.ExcludeTrailingBackSlash method).

To copy several folders, use wildcards (* and ?) to specify the mask. Note, that wildcards are only allowed in the last component of the path.

Destination

The path to the folder where the folder(s) specified by the Source parameter will be copied along with their contents. Both fully-qualified and relative paths are acceptable. This path may or may not include a trailing backslash. If the destination folder does not exist, it will be created.

Note that if the Source mask does not match any folder, the destination folder is not created.

RenameOnCollision

Specifies the method behavior in case the Destination folder already contains a subfolder with the same name as the Source folder. If RenameOnCollision is True (which is the default value), the method creates the Copy of <FolderName> subfolder in the Destination folder and copies the Source’s contents to that subfolder. Otherwise, the method copies the Source folder’s contents to the existing destination subfolder replacing the files having the same name.

Result Value

True if all the specified folders were copied successfully, and False otherwise.

If the Source folder was not found, the method returns False. However, if the Source mask that uses wildcards does not match any folder, the method returns True.

Remarks

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

Example

The following statement creates a copy of the C:\MyFolder folder in C:\TempFolder:

JavaScript, JScript

aqFileSystem.CopyFolder("C:\\MyFolder", "C:\\TempFolder");

Python

aqFileSystem.CopyFolder("C:\\MyFolder", "C:\\TempFolder")

VBScript

Call aqFileSystem.CopyFolder("C:\MyFolder", "C:\TempFolder")

DelphiScript

aqFileSystem.CopyFolder('C:\MyFolder', 'C:\TempFolder\');

C++Script, C#Script

aqFileSystem["CopyFolder"]("C:\\MyFolder", "C:\\TempFolder");

The following statement copies all subfolders of C:\MyFolder whose names end with “Project” to C:\TempFolder:

JavaScript, JScript

aqFileSystem.CopyFolder("C:\\MyFolder\\*Project", "C:\\TempFolder");

Python

aqFileSystem.CopyFolder("C:\\MyFolder\\*Project", "C:\\TempFolder")

VBScript

Call aqFileSystem.CopyFolder("C:\MyFolder\*Project", "C:\TempFolder")

DelphiScript

aqFileSystem.CopyFolder('C:\MyFolder\*Project', 'C:\TempFolder');

C++Script, C#Script

aqFileSystem["CopyFolder"]("C:\\MyFolder\\*Project", "C:\\TempFolder");

See Also

Working With Files From Scripts
MoveFolder Method
RenameFolder Method
DeleteFolder Method
Exists Method
Copy Method
CopyFile Method
Exists Method
GetCurrentFolder Method
SetCurrentFolder Method

Highlight search results