RemoveDirectory()

Purpose

RemoveDirectory deletes a directory from a disk. The function will not delete any files or subdirectories inside the directory. If the directory to delete is not completely empty, the function will fail.

 
Library   Transcribed by Date of page Updated on

Kernel32.dll

-

Jacques Paris

21.03.03

-

 
Restrictions on use
-
 
Declare 32-bit

Declare Function RemoveDirectory Lib "kernel32.dll" Alias "RemoveDirectoryA" (

    ByVal lpPathName As String

    ) As Integer

 
Required Type definition
-
 
Parameters

lpPathName

The directory to delete. The directory must be completely empty.

 
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
 
Example

' Delete the directory stored in a variable

 

Dim retval As Long   ' return value

Dim a_dir as string  ' variable to store directory 'name'

 

a_dir="C:\MyDocuments\Maps\TempData"
retval = RemoveDirectory(a_dir)  
If retval = 1 Then                                        
  Print a_dir+" was successfully deleted."
Else
  Print "Deletion failed.  Make sure "+a_dir+" is empty."
End If

 
Comments
-
 
See also
CreateDirectoryEx(), CreateFile(), CreateDirectory()