aqFileSystem.GetCurrentFolder Method

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

Description

Use the GetCurrentFolder method to find out which folder is currently selected. To define another folder as the current one, use the SetCurrentFolder method.

Declaration

aqFileSystem.GetCurrentFolder()

Result String

Applies To

The method is applied to the following object:

Result Value

A string that holds the path to the current folder.

Remarks

If your project contains event handlers, then the test engine resets the current folder to the project’s folder every time an event handler runs. You have to set the desired current folder with the aqFileSystem.SetCurrentFolder method at the end of the event handling routine.

Example

The code below obtains the name of the current folder and then posts the names of all the files located in it to the log.

JavaScript, JScript

function GetCurrentFolderExample()
{
   // Obtains the name of the current folder
   var sCurFold = aqFileSystem.GetCurrentFolder();
   
   // Obtains information about the folder
   var FoldInfo = aqFileSystem.GetFolderInfo(sCurFold);
   
   // Gets the collection of the files located in the folder
   var FileCol = FoldInfo.Files;
   
   // Posts the file names to the test log
   while ( FileCol.HasNext() )
   {
     var aFile = FileCol.Next();
     Log.Message(aFile.Name)
   }
}

Python

def GetCurrentFolderExample():
  # Obtains the name of the current folder
  sCurFold = aqFileSystem.GetCurrentFolder()
  # Obtains information about the folder
  FoldInfo = aqFileSystem.GetFolderInfo(sCurFold)
  # Gets the collection of the files located in the folder
  FileCol = FoldInfo.Files
  # Posts the file names to the test log
  while FileCol.HasNext():
    aFile = FileCol.Next()
    Log.Message(aFile.Name)

VBScript

Sub GetCurrentFolderExample
   Dim sCurFold, FoldInfo, FileCol, aFile

   ' Obtains the name of the current folder
   sCurFold = aqFileSystem.GetCurrentFolder
   
   ' Obtains information about the folder
   Set FoldInfo = aqFileSystem.GetFolderInfo(sCurFold)
   
   ' Gets the collection of the files located in the folder
   Set FileCol = FoldInfo.Files
   
   ' Posts the file names to the test log
   While FileCol.HasNext
     Set aFile = FileCol.Next
     Call Log.Message(aFile.Name)
   WEnd
End Sub

DelphiScript

procedure GetCurrentFolderExample;
var sCurFold, FoldInfo, FileCol, aFile;
begin
   // Obtains the name of the current folder
   sCurFold := aqFileSystem.GetCurrentFolder;
   
   // Obtains information about the folder
   FoldInfo := aqFileSystem.GetFolderInfo(sCurFold);
   
   // Gets the collection of the files located in the folder
   FileCol := FoldInfo.Files;
   
   // Posts the file names to the test log
   while FileCol.HasNext do
   begin
     aFile := FileCol.Next;
     Log.Message(aFile.Name)
   end;
end;

C++Script, C#Script

function GetCurrentFolderExample()
{
   // Obtains the name of the current folder
   var sCurFold = aqFileSystem["GetCurrentFolder"]();
   
   // Obtains information about the folder
   var FoldInfo = aqFileSystem["GetFolderInfo"](sCurFold);
   
   // Gets the collection of the files located in the folder
   var FileCol = FoldInfo["Files"];
   
   // Posts the file names to the test log
   while ( FileCol["HasNext"]() )
   {
     var aFile = FileCol["Next"]();
     Log["Message"]( aFile["Name"] )
   }
}

See Also

Working With Files From Scripts
SetCurrentFolder Method
DeleteFolder Method
CreateFolder Method

Highlight search results