Function RemoveDir() Foundation

Removes a directory

RemoveDir( <cDirectory> [,<lForce>] ) --> lSuccess
The argument <cDirectory> is the name of the directory to be removed.
When the value for the optional parameter <lForce> is .T. (true), the directory is removed even if it is not empty. In this case, all files and subdirectories are deleted prior to removing the directory. The default value is .F. (false).

The return value of RemoveDir() is .T. if the directory could be removed successfully or .F. if not. If .F. is returned the exact error code can be obtained by FError().


The function removes a directory with the specified name. If no path was provided within the specified name the directory to be removed must be a subdirectory of the current directory.

If a directory can not be removed because a file or folder in the directory is being accessed by another process the function fails and FError() may return the error codes 32 (The process cannot access the file because it is being used by another process) or 145 (The directory is not empty).

Remove directories
// The example shows various ways how 
// to remove a directory 

   ? RemoveDir("C:\MYAPP") 
   ? RemoveDir("subdir") 
   ? RemoveDir(Getenv("TEMP")+"\mytemp") 
   ? RemoveDir('"\\srvgr4\bin\download\latest files"') 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.