How to delete a file from a C ++ application without a console window in Windows?

I need to delete a temporary file from my Windows C ++ application (developed in Borland C ++ Builder). I am currently using a simple one:

system("del tempfile.tmp"); 

This makes the console window blink in front of my application, and it does not look very professional. How can I do this without a console window?

+4
source share
3 answers

It looks like you need Win32 DeleteFile () function. You will need #include <windows.h> to use it.

+15
source

Or even the standard C library function int remove( const char *path ); .

+16
source

For a little more portable (Ie, which works on both Windows and UNIX), I use unlink () or the ISO compatible _unlink () in io.h (unlink () for UNIX includes unistd.h)
Delete () actually calls _unlink ().

+2
source

All Articles