Name Property

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

Description

The Name property returns the name (without the path) and extension of the file specified by the given aqFileInfoObj object.

Declaration

aqFileInfoObj.Name

Read-Only Property String
aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object

Applies To

The property is applied to the following object:

Property Value

A string containing the name (without the path) and extension of the file.

Example

The code below obtains the collection of all the files located in the specified folder and posts the files' names with extensions to the test log.

JavaScript, JScript

function FileNameExample()
{
 // Sets the path to the desired folder
 FolPath = "C:\\MyFiles";
 
 // Gets the total number of the files located in the folder
 var FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count;
 
 var FileItems = aqFileSystem.GetFolderInfo(FolPath).Files;
 
 // Posts the names of all the files located in the folder to the test log
 for (var i = 0; i<FilesNum; i++)
  Log.Message(FileItems.Item(i).Name)
 
}

Python

def FileNameExample():
  # Sets the path to the desired folder
  FolPath = "C:\\MyFiles"
  
  # Gets the total number of the files located in the folder 
  FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count
  FileItems = aqFileSystem.GetFolderInfo(FolPath).Files
  
  # Posts the names of all the files located in the folder to the test log
  for i in range(0, FilesNum):
    Log.Message(FileItems.Item(i).Name)

VBScript

Sub FileNameExample

 ' Sets the path to the desired folder
 FolPath = "C:\MyFiles"
 
 ' Gets the total number of the files located in the folder
 FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count
 
 Set FileItems = aqFileSystem.GetFolderInfo(FolPath).Files
 
 ' Posts the names of all the files located in the folder to the test log
 For i = 0 to FilesNum-1
  Call Log.Message(FileItems.Item(i).Name)
 Next
 
End Sub

DelphiScript

function FileNameExample;
var FolPath, FilesNum, FileItems, i;
begin

 // Sets the path to the desired folder
 FolPath := 'C:\MyFiles';
 
 // Gets the total number of the files located in the folder
 FilesNum := aqFileSystem.GetFolderInfo(FolPath).Files.Count;
 
 FileItems := aqFileSystem.GetFolderInfo(FolPath).Files;
 
 // Posts the names of all the files located in the folder to the test log
 For i := 0 to (FilesNum - 1) do
  Log.Message(FileItems.Item(i).Name);
 
end;

C++Script, C#Script

function FileNameExample()
{

 // Sets the path to the desired folder
 FolPath = "C:\\MyFiles";
 
 // Gets the total number of the files located in the folder
 var FilesNum = aqFileSystem["GetFolderInfo"](FolPath)["Files"]["Count"];
 
 var FileItems = aqFileSystem["GetFolderInfo"](FolPath)["Files"];
 
 // Posts the names of all the files located in the folder to the test log
 for (var i = 0; i<FilesNum; i++)
  Log["Message"]( FileItems["Item"](i)["Name"] )
 
}

See Also

Working With Files From Scripts
GetFileInfo Method
FindFiles Method
Path Property
Drive Property

Highlight search results