Export (0) Print
Expand All
div
eof
Expand Minimize

remove, _wremove 

Delete a file.


int remove(
   const char *path 
);
int _wremove(
   const wchar_t *path 
);

Parameters

path

Path of file to be removed.

Each of these functions returns 0 if the file is successfully deleted. Otherwise, it returns -1 and sets errno either to EACCES to indicate that the path specifies a read-only file or the file is open, or to ENOENT to indicate that the filename or path was not found or that the path specifies a directory.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these and other return codes.

The remove function deletes the file specified by path. _wremove is a wide-character version of _remove; the path argument to _wremove is a wide-character string. _wremove and _remove behave identically otherwise. All handles to a file must be closed before it can be deleted.

Generic-Text Routine Mappings
TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined

_tremove

remove

remove

_wremove

Routine Required header Compatibility

remove

<stdio.h> or <io.h>

ANSI, Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_wremove

<stdio.h> or <wchar.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

// crt_remove.c
/* This program uses remove to delete crt_remove.txt */

#include <stdio.h>

int main( void )
{
   if( remove( "crt_remove.txt" ) == -1 )
      perror( "Could not delete 'CRT_REMOVE.TXT'" );
   else
      printf( "Deleted 'CRT_REMOVE.TXT'\n" );
}

This file will be deleted.

Deleted 'CRT_REMOVE.TXT'

Community Additions

ADD
Show:
© 2014 Microsoft