RemoveDirectory
The RemoveDirectory
function deletes an existing empty directory.
BOOL RemoveDirectory(
_In_ LPCTSTR lpPathName
);
Parameters
Parameter | Description |
---|---|
lpPathName |
A pointer to a null-terminated string that names the directory to be deleted. This parameter can be a path. For more information, see Path and Filename Syntax. |
Return Value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError
.
Requirements
Supported client operating systems | Minimum supported version |
---|---|
Windows 2000 Professional | Windows 2000 |
Windows XP | Windows XP |
Windows Server 2003 | Windows Server 2003 |
Windows Vista | Windows Vista |
Windows Server 2008 | Windows Server 2008 |
Windows 7 | Windows 7 |
Windows Server 2008 R2 | Windows Server 2008 R2 |
Windows 8 | Windows 8 |
Windows Server 2012 | Windows Server 2012 |
Windows 8.1 | Windows 8.1 |
Windows Server 2012 R2 | Windows Server 2012 R2 |
Windows 10 | Windows 10 |
Windows Server 2016 | Windows Server 2016 |
Windows Server 2019 | Windows Server 2019 |
Windows Server 2022 | Windows Server 2022 |
Supported minimum dll file | msvcrt.dll |
---|---|
Header | windows.h |
---|---|
Library | Kernel32.lib |
---|---|
DLL | Kernel32.dll |
---|---|
Remarks
To delete a directory, the calling process must have the appropriate access permissions to the directory.
This function can only delete empty directories. If the directory is not empty, the function fails and GetLastError
returns ERROR_DIR_NOT_EMPTY
.
To delete a directory that is not empty, you must first delete all files and subdirectories within it.
The behavior of this function may be affected by a file system filter driver that is running on the system. For example, functions that might take a long time to complete are not pruned by default in these situations. If the directory contains reparse points, the function operates on the reparse point directory itself rather than the target of the reparse point.