Deleting Files From the Files Collection

Applies to TestComplete 14.10, last modified on June 5, 2019

The Files collection of the Stores project item contains files that you can use for testing. The stored files that you no longer need can be deleted from the collection either from the Files editor, or from tests.

Deleting Files From the Files Editor

To delete a file from the Files collection of the Stores project item:

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

  • 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.

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

Deleting Files From Tests

To delete files from the Files collection in your scripts and keyword tests, use the Remove method of the Files object. 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 files from the Files collection with the Remove method in your keyword tests, use the Call Object Method, Run Code Snippet or Run Script Routine operation.

See Also

About Files Collection
About Files Editor

Highlight search results