Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Delete a directory.
int_rmdir(constchar*dirname);
int_wrmdir(constwchar_t*dirname);
| Routine | Required Header | Compatibility |
| _rmdir | <direct.h> | Win 95, Win NT |
| _wrmdir | <direct.h> or <wchar.h> | Win NT |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
| LIBC.LIB | Single thread static library, retail version |
| LIBCMT.LIB | Multithread static library, retail version |
| MSVCRT.LIB | Import library for MSVCRT.DLL, retail version |
Return Value
Each of these functions returns 0 if the directory is successfully deleted. A return value of –1 indicates an error, and errno is set to one of the following values:
ENOTEMPTY
Given path is not a directory; directory is not empty; or directory is either current working directory or root directory.
ENOENT
Path is invalid.
Parameter
dirname
Path of directory to be removed
Remarks
The _rmdir function deletes the directory specified by dirname. The directory must be empty, and it must not be the current working directory or the root directory.
_wrmdir is a wide-character version of _rmdir; the dirname argument to _wrmdir is a wide-character string. _wrmdir and _rmdir behave identically otherwise.
Generic-Text Routine Mappings
| TCHAR.H Routine | _UNICODE & _MBCS Not Defined | _MBCS Defined | _UNICODE Defined |
| _trmdir | _rmdir | _rmdir | _wrmdir |
Example
/* MAKEDIR.C */
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
if( _mkdir( "\\testtmp" ) == 0 )
{
printf( "Directory '\\testtmp' was successfully created\n" );
system( "dir \\testtmp" );
if( _rmdir( "\\testtmp" ) == 0 )
printf( "Directory '\\testtmp' was successfully removed\n" );
else
printf( "Problem removing directory '\\testtmp'\n" );
}
else
printf( "Problem creating directory '\\testtmp'\n" );
}
Output
Directory '\testtmp' was successfully created
Volume in drive C is CDRIVE
Volume Serial Number is 0E17-1702
Directory of C:\testtmp
05/03/94 12:30p <DIR> .
05/03/94 12:30p <DIR> ..
2 File(s) 0 bytes
17,358,848 bytes free
Directory '\testtmp' was successfully removed