Remove Method

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The Remove method lets you remove the specified item from the Files, Objects or Regions collection and optionally removes the related file from the disk.

Declaration

ProgObj.Remove(Name, RemoveFromDisk)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
Name [in]    Required    String    
RemoveFromDisk [in]    Optional    Boolean Default value: False   
Result Boolean

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameters:

Name

Unique name of the collection item to be removed from the collection.

RemoveFromDisk

If this parameter is True, the file that corresponds to the item will be removed from the disk. Otherwise, the file will remain on the disk (this is the default).

Result Value

If the item was removed successfully, the Remove method returns True. Otherwise, it returns False and generates an error string, which you can retrieve from the LastError property (and post to the test log if you wish).

Example

The following code snippet obtains the name of the item that stores the specified file and then deletes this item from the Stores | Files collection:

JavaScript, JScript

ItemName = Files.NameByFileName("D:\\Data\\MyFile.txt");

// Removes the item from the project, but keeps the corresponding file on the disk.
Files.Remove(ItemName);

Python

ItemName = Files.NameByFileName("D:\\Data\\MyFile.txt")
# Removes the item from the project, but keeps the corresponding file on the disk. 
Files.Remove(ItemName)

VBScript

ItemName = Files.NameByFileName("D:\Data\MyFile.txt")

' Removes the item from the project, but keeps the corresponding file on the disk.
Call Files.Remove(ItemName)

DelphiScript

ItemName := Files.NameByFileName('D:\Data\MyFile.txt');

// Removes the item from the project, but keeps the corresponding file on the disk.
Files.Remove(ItemName);

C++Script, C#Script

ItemName = Files["NameByFileName"]("D:\\Data\\MyFile.txt");

// Removes the item from the project, but keeps the corresponding file on the disk.
Files["Remove"](ItemName);

See Also

Add Method
LastError Method

Highlight search results