Download EaseFilter Monitor, Control and Encryption Filter Driver SDK Setup File Download EaseFilter Monitor, Control and Encryption Filter Driver SDK Zip File
Deletes an existing file.
To perform this operation as a transacted operation, use the DeleteFileTransacted function.
BOOL DeleteFile( LPCTSTR lpFileName );
lpFileName
The name of the file to be deleted.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?" to the path. For more information, see Naming a File.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
If an application attempts to delete a file that does not exist, the DeleteFile function fails with ERROR_FILE_NOT_FOUND. If the file is a read-only file, the function fails with ERROR_ACCESS_DENIED.
The following list identifies some tips for deleting, removing, or closing files:
If you request delete permission at the time you create a file, you can delete or rename the file with that handle, but not with any other handle. For more information, see File Security and Access Rights.
The DeleteFile function fails if an application attempts to delete a file that has other handles open for normal I/O or as a memory-mapped file (FILE_SHARE_DELETE must have been specified when other handles were opened).
The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to CreateFile to open the file fail with ERROR_ACCESS_DENIED.
Symbolic link behavior—
If the path points to a symbolic link, the symbolic link is deleted, not the target. To delete a target, you must call CreateFile and specify FILE_FLAG_DELETE_ON_CLOSE.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.