The Windows Disk Management 15




Another Deleting File Program Example


Create a new empty Win32 console application project. Give a suitable project name and change the project location if needed.



Then, add the source file and give it a suitable name.




Next, add the following source code.


#include <windows.h>

#include <stdio.h>


int main(int argc, char *argv[])


    BOOL fSuccess = FALSE;


    fSuccess = DeleteFile(TEXT(C:\\testing.txt));

    if (!fSuccess)


        // Handle the error.

       printf (DeleteFile() failed, error %d\n, GetLastError());

       return (6);



            printf (DeleteFile() is  OK!\n);

    return (0);




Build and run the project. The following screenshot is a sample output.


Another Deleting File Program Example: A sample console program output in action


The Unicode version can be found in the download page.




< Windows Disk 14 | Win32 Programming Index Page | Windows Disk Index | Windows Disk 16 >