DeleteFile Method

 

Description

 

Deletes a specified file.

 

PowerBASIC Syntax

 

METHOD DeleteFile ( _

BYVAL bstrFileSpec AS STRING, _

OPTIONAL BYVAL bForce AS INTEGER _

)

 

Arguments

 

bstrFileSpec

BSTR. The name of the file to delete. bstrFileSpec can contain wildcard characters in the last path component.

bForce

Boolean value that is true if files with the read-only attribute set are to be deleted; false (default) if they are not.

 

Remarks

 

An error occurs if no matching files are found. The DeleteFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes that were made before an error occurred.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Delete a file

fso.DeleteFile UCODE$("C:\MyFolder\Test.txt"), %FALSE

IF OBJRESULT = %S_OK THEN

  MSGBOX "File deleted"

ELSE

  MSGBOX "Error &H" & HEX$(OBJRESULT) & " deleting the file"

END IF

 

Valid XHTML 1.0 Transitional