Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
_rmdir, _wrmdir
Delete a directory.
int_rmdir(constchar*dirname);
int_wrmdir(constwchar_t*dirname);
For additional compatibility information, see Compatibility in the Introduction.
Libraries
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
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