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

Related Call: CreateDirectory
Category: Files
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/r/removedirectory.html