DeleteFileA function
The DeleteFileA function deletes an existing file.
BOOL DeleteFileA(
_In_ LPCSTR lpFileName
);
Parameters
| Parameter | Type | Description |
|---|---|---|
lpFileName |
_In_ LPCSTR |
The name of the file to be deleted. This parameter can be a fully qualified path or a path relative to the current directory. |
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.
Remarks
If the specified file is a read-only file, the function will fail and return FALSE. The application must explicitly remove the read-only attribute before calling DeleteFileA.
If the specified file is a hidden file or a system file, the function will fail and return FALSE. The application must explicitly remove the hidden or system attribute before calling DeleteFileA.
If the specified file is currently in use by another process, the function will fail and return FALSE. The system will not delete the file until the last handle to it is closed.
You can use DeleteFileA to delete a file on a remote computer if the share name, file name, and credentials are valid.
The DeleteFileA function works on files that are marked for deletion at the next reboot. For more information, see SetDeleteOnReboot.
Requirements
| Attribute | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | fileapi.h (include windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
| ANSI/Unicode and UTF-8 | DeleteFileA (ANSI) and DeleteFileW (Unicode) are defined in winbase.h. DeleteFile is defined in winbase.h. |