aqFileSystem Object

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The aqFileSystem object lets you work with the computer’s file system: obtain information about drives, folders and files as well as to add, modify and remove files and folders.

The object is available in TestComplete by default.

Members

Example

The following code snippet searches for all EXE files in the C:\Work folder.

JavaScript

function FileFinder()
{
  var foundFiles, aFile;
  foundFiles = aqFileSystem.FindFiles("C:\\Work\\", "*.exe");
  if (!strictEqual(foundFiles, null))
    while (foundFiles.HasNext())
    {
      aFile = foundFiles.Next();
      Log.Message(aFile.Name);
    }
  else
    Log.Message("No files were found.");
}

JScript

function FileFinder()
{
  var foundFiles, aFile;
  foundFiles = aqFileSystem.FindFiles("C:\\Work\\", "*.exe");
  if (foundFiles != null)
    while (foundFiles.HasNext())
    {
      aFile = foundFiles.Next();
      Log.Message(aFile.Name);
    }
  else
    Log.Message("No files were found.");
}

Python

def FileFinder():
  foundFiles = aqFileSystem.FindFiles("C:\\Work\\", "*.exe")
  if foundFiles != None:
    while foundFiles.HasNext():
      aFile = foundFiles.Next()
      Log.Message(aFile.Name)
    else:
      Log.Message("No files were found.")

VBScript

Sub FileFinder
  Set foundFiles = aqFileSystem.FindFiles("C:\Work\", "*.exe")
  If Not foundFiles Is Nothing Then
     While foundFiles.HasNext
       Set aFile = foundFiles.Next
       Log.Message aFile.Name
     Wend
  Else
      Log.Message "No files were found."
  End If
End Sub

DelphiScript

procedure FileFinder;
var foundFiles, aFile;
begin
  foundFiles := aqFileSystem.FindFiles('C:\Work\', '*.exe');
  if foundFiles <> nil then
    while foundFiles.HasNext do
    begin
      aFile := foundFiles.Next;
      Log.Message(aFile.Name);
    end
  else
    Log.Message('No files were found.');
end;

C++Script, C#Script

function FileFinder()
{
  var foundFiles, aFile;
  foundFiles = aqFileSystem["FindFiles"]("C:\\Work\\", "*.exe");
  if (foundFiles != null)
    while (foundFiles["HasNext"]())
    {
      aFile = foundFiles["Next"]();
      Log["Message"](aFile["Name"]);
    }
  else
    Log["Message"]("No files were found.");
}

See Also

Working With Files From Scripts
TestComplete Helper Objects
aqConvert Object
aqDateTime Object
aqEnvironment Object
aqFile Object
aqObject Object
aqString Object
aqUtils Object

Highlight search results