How to delete a file using the Win32 API in C

1 Answer

0 votes
#include <windows.h>
#include <stdio.h>

int main(void) {
    const char* filename = "D:\\test.htm";

    if (DeleteFileA(filename)) {
        printf("File deleted successfully.\n");
    }
    else {
        printf("Failed to delete file. Error: %lu\n", GetLastError());
    }

    return 0;
}




/*
run:

File deleted successfully.

*/

 



answered Feb 6 by avibootz
...