Delete Method

 

Description

 

Deletes a specified file.

 

PowerBASIC Syntax

 

METHOD Delete (BYVAL bForce AS INTEGER)

 

Arguments

 

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 the specified folder does not exist.

 

The results of the Delete method on a File are identical to operations performed using FileSystemObject.DeleteFile.

 

The Delete method does not distinguish between files that have contents and those that do not. The specified file is deleted regardless of whether or not it has contents.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

DIM pFile AS IFile

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Get a reference to the IFile interface

pFile = fso.GetFile(UCODE$("C:\MyFolder\MyFile.txt"))

' Delete the file

pFile.Delete %VARIANT_TRUE

IF OBJRESULT = %S_OK THEN

  MSGBOX "File deleted"

ELSE

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

END IF

 

Valid XHTML 1.0 Transitional