aqFileSystem.DeleteFile Method

Applies to TestComplete 15.0, last modified on November 17, 2021

Description

Use the DeleteFile method to remove one or more files from the disk.

Declaration

aqFileSystem.DeleteFile(PathToFile)

PathToFile [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

PathToFile

The fully qualified path (including the name) to the file to be deleted. To delete several files, use wildcards (* and ?) to specify the mask. Note, that wildcards are only allowed in the file names, not in paths.

Result Value

True if all the specified files were deleted successfully, and False otherwise.

If the specified file was not found, the method returns True.

Remarks

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

Example

The following example demonstrates how you can use the DeleteFile method:

JavaScript, JScript

  //The following line deletes File1.txt from the Test folder
 aqFileSystem.DeleteFile("D:\\Test\\File1.txt")

  //The following line deletes all files with the .tmp extension from the Test folder
 aqFileSystem.DeleteFile("D:\\Test\\*.tmp")

Python

# The following line deletes File1.txt from the Test folder
aqFileSystem.DeleteFile("D:\\Test\\File1.txt")
# The following line deletes all files with the .tmp extension from the Test folder
aqFileSystem.DeleteFile("D:\\Test\\*.tmp")

VBScript

  'The following line deletes the File1.txt file from the Test folder
 aqFileSystem.DeleteFile("D:\Test\File1.txt")

  'The folowing line deletes all files with the .tmp extension from the Test folder
 aqFileSystem.DeleteFile("D:\Test\*.tmp")

DelphiScript

  //The following line deletes File1.txt from the Test folder
 aqFileSystem.DeleteFile('D:\Test\File1.txt');

  //The following line deletes all files with the .tmp extension from the Test folder
 aqFileSystem.DeleteFile('D:\Test\*.tmp');

C++Script, C#Script

  /*The following line deletes File1.txt from the Test folder*/
 aqFileSystem["DeleteFile"]("D:\\Test\\File1.txt")

  /*The following line deletes all files with the .tmp extension from the Test folder*/
 aqFileSystem["DeleteFile"]("D:\\Test\\*.tmp")

See Also

Working With Files From Scripts
Exists Method
DeleteFolder Method
MoveFile Method
CopyFile Method

Highlight search results