DeleteFolder Method

 

Description

 

Deletes a specified folder and its contents.

 

PowerBASIC Syntax

 

METHOD DeleteFolder ( _

BYVAL bstrFolderSpec AS STRING, _

OPTIONAL BYVAL bForce AS INTEGER _

)

 

Arguments

 

bstrFolderSpec

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

bForce

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

 

Remarks

 

The DeleteFolder method does not distinguish between folders that have contents and those that do not. The specified folder is deleted regardless of whether or not it has contents.

 

An error occurs if no matching folders are found. The DeleteFolder 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 folder

fso.DeleteFolder UCODE$("C:\MyFolder"), %FALSE

IF OBJRESULT = %S_OK THEN

  MSGBOX "Folder deleted"

ELSE

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

END IF

 

Valid XHTML 1.0 Transitional