RemoveDirectory Function

Declare Function RemoveDirectory Lib "kernel32.dll" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Long

Platforms: Win 32s, Win 95/98, Win NT

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. The function returns 1 if successful, or 0 if an error occured.

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

Example:

' Delete the directory C:\MyPrograms\TempData.
Dim retval As Long  ' return value

retval = RemoveDirectory("C:\MyPrograms\TempData")  ' delete the directory
If retval = 1 Then  ' success
  Debug.Print "C:\MyPrograms\TempData was successfully deleted."
Else
  Debug.Print "Deletion failed.  Make sure C:\MyPrograms\TempData is empty."
End If

See Also: CreateDirectory
Category: Files

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/r/removedirectory.html