Delete Method

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

Use the Delete method to delete the folder to which the given aqFolderInfoObj object corresponds.

Declaration

aqFolderInfoObj.Delete(Confirm)

aqFolderInfoObj An expression, variable or parameter that specifies a reference to an aqFolderInfo object
Confirm [in]    Optional    Boolean Default value: False   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Confirm

Specifies whether the method should remove non-empty folders. If the parameter's value is False, the method removes folders only if they do not contain any files. If the parameter's value is True, the method removes non-empty folders as well.

Result Value

True if the folder was deleted successfully, and False if it was not.

Remarks

If the method fails to delete the folder, TestComplete will post an information message to the test log explaining the cause of the failure.

Example

The code below creates a temporary folder, adds a file to it and then deletes this folder at the end of the test.

JavaScript, JScript

function DeletingFolder()
{

 var sPath = "C:\\Temp";
 
 // Creates a folder
 aqFileSystem.CreateFolder(sPath);
 
 var FolderInf = aqFileSystem.GetFolderInfo(sPath);

 // Adds a file to the folder
 aqFile.Create(sPath + "\\TempFile.txt");
 
 // Performs some actions over the file's content
 
 // Deletes both the folder and the file
 FolderInf.Delete(true);

}

Python

def DeletingFolder():
  sPath = "C:\\Temp"
  # Creates a folder
  aqFileSystem.CreateFolder(sPath)
  FolderInf = aqFileSystem.GetFolderInfo(sPath)
  # Adds a file to the folder
  aqFile.Create(sPath + "\\TempFile.txt")
  # Performs some actions over the file's content
  # Deletes both the folder and the file
  FolderInf.Delete(True)

VBScript

Sub DeletingFolder

 sPath = "C:\Temp"
  
 ' Creates a folder
 Call aqFileSystem.CreateFolder(sPath)
 
 Set FolderInf = aqFileSystem.GetFolderInfo(sPath)
 
 ' Adds a file to the folder
 Call aqFIle.Create(sPath & "\TempFile.txt")
 
 ' Performs some actions over the file's content
 
 ' Deletes both the folder and the file
 Call FolderInf.Delete(true)
 
End Sub

DelphiScript

function DeletingFolder;
var sPath, FolderInf;
begin
 sPath := 'C:\Temp';
 
 // Creates a folder
 aqFileSystem.CreateFolder(sPath);
 
 FolderInf := aqFileSystem.GetFolderInfo(sPath);

 // Adds a file to the folder
 aqFile.Create(sPath + '\TempFile.txt');
 
 // Performs some actions over the file's content
 
 // Deletes both the folder and the file
 FolderInf.Delete(true);
end;

C++Script, C#Script

function DeletingFolder()
{
 var sPath = "C:\Temp";
 
 // Creates a folder
 aqFileSystem["CreateFolder"](sPath);
 
 var FolderInf = aqFileSystem.GetFolderInfo(sPath);

 // Adds a file to the folder
 aqFile.Create(sPath + "\\TempFile.txt");
 
 // Performs some actions over the file's content
 
 // Deletes both the folder and the file
 FolderInf["Delete"](true);
}

See Also

Working With Files From Scripts
Copy Method
Move Method
Rename Method
aqFileSystem.CopyFolder Method
aqFileSystem.GetCurrentFolder Method
aqFileSystem.SetCurrentFolder Method

Highlight search results