NameByFileName Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The NameByFileName method lets you obtain the name of the item in the Files, Objects or Regions collection that refers to the specified file.

Declaration

ProgObj.NameByFileName(FileName)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
FileName [in]    Required    String    
Result String

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

FileName

Full path to the file referred to by the collection's item whose name you want to get.

Result Value

Unique name of the item in the collection that refers to the specified file.

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

FileNameByIndex Method
FileNameByName Method
NameByIndex Method
NamesList Method

Highlight search results