Files Property

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

Description

Use the aqDriveInfo.Files property to get access to the files located in the root folder.

Declaration

aqDriveInfoObj.Files

Read-Only Property The aqObjIterator object
aqDriveInfoObj An expression, variable or parameter that specifies a reference to an aqDriveInfo object

Applies To

The property is applied to the following object:

Property Value

An aqObjIterator object whose items are aqFileInfo objects that correspond to the files stored in the root folder. If the drive’s root folder does not contain files, the property returns an empty value (null in JavaScript, JScript, C#Script and C++Script, None in Python, Nothing in VBScript, nil in DelphiScript).

Example

The code below demonstrates how to obtain the total number of files located in a drive's root folder.

JavaScript

function CalculatingRootFilesNumber()
{

  // Specifies the desired drive
  let Drive = "C";

  // Obtains a collection of files stored in the drive's root folder
  let FilesCol = aqFileSystem.GetDriveInfo(Drive).Files;

  // Checks whether the file collection is empty
  if (!strictEqual(FilesCol, null))
    // Posts the total number of files the drive's root folder contains to the log
    Log.Message(FilesCol.Count);
  else
    Log.Message("The root folder of the " + Drive + " drive contains no files");

}

JScript

function CalculatingRootFilesNumber()
{

  // Specifies the desired drive
  var Drive = "C";

  // Obtains a collection of files stored in the drive's root folder
  var FilesCol = aqFileSystem.GetDriveInfo(Drive).Files;

  // Checks whether the file collection is empty
  if (FilesCol != null)
    // Posts the total number of files the drive's root folder contains to the log
    Log.Message(FilesCol.Count);
  else
    Log.Message("The root folder of the " + Drive + " drive contains no files");

}

Python

def CalculatingRootFilesNumber():
  # Specifies the desired drive
  Drive = "C"
  # Obtains a collection of files stored in the drive's root folder
  FilesCol = aqFileSystem.GetDriveInfo(Drive).Files
  # Checks whether the file collection is empty
  if FilesCol != None:
    # Posts the total number of files the drive's root folder contains to the log
    Log.Message(FilesCol.Count)
  else:
    Log.Message("The root folder of the " + str(Drive) + " drive contains no files")

VBScript

Sub CalculatingRootFilesNumber
  Dim Drive, FilesCol

  ' Specifies the desired drive
  Drive = "C"

  ' Obtains a collection of files stored in the drive's root folder
  Set FilesCol = aqFileSystem.GetDriveInfo(Drive).Files

  ' Checks whether the file collection is empty
  If Not FilesCol is Nothing Then

    ' Posts the total number of files the drive's root folder contains to the log
    Log.Message(FilesCol.Count)
  Else
    Log.Message("The root folder of the " & Drive & " drive contains no files")
  End If

End Sub

DelphiScript

procedure CalculatingRootFilesNumber();
var Drive, FilesCol;
begin

  // Specifies the desired drive
  Drive := 'C';

  // Obtains a collection of files stored in the drive's root folder
  FilesCol := aqFileSystem.GetDriveInfo(Drive).Files;

  // Checks whether the file collection is empty
  if FilesCol <> nil then
    // Posts the total number of files the drive's root folder contains to the log
    Log.Message(FilesCol.Count)
  else
    Log.Message('The root folder of the ' + Drive + ' drive contains no files');

end;

C++Script, C#Script

function CalculatingRootFilesNumber()
{

  // Specifies the desired drive
  var Drive = "C";

  // Obtains a collection of files stored in the drive's root folder
  var FilesCol = aqFileSystem["GetDriveInfo"](Drive)["Files"];

  // Checks whether the file collection is empty
  if (FilesCol != null)
    // Posts the total number of files the drive's root folder contains to the log
    Log["Message"](FilesCol["Count"]);
  else
    Log["Message"]("The root folder of the " + Drive + " drive contains no files");

}

See Also

aqFileSystem Object
aqFileInfo Object

Highlight search results