Deleting Files From the Files Collection

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

The Stores > Files collection of a project contains files that you can use for file comparison and verification in your tests. You can delete the files you no longer need:

From TestComplete UI

  1. Select the needed file in the Files editor and either choose Delete from the context menu or press Del.

  2. Once you do this, you will be asked whether you want to remove the item from the project (but keep the corresponding file), or whether you want to completely delete the item file from the disk.

  3. Select the action you want by pressing the Remove or Delete button.

From Tests

To delete files from the Files collection in your scripts and keyword tests, use the Files.Remove method. This method removes the specified stored file from the collection.

The following code snippet obtains the name of the item that stores the specified file and then deletes this item from the 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);

To delete stored files from keyword tests, call the Files.Remove method by using the Call Object Method, Run Code Snippet or Run Script Routine operation.

See Also

Files
Files Editor

Highlight search results