Programmatically deleting a file

I am holding a path of a file in a variable and I want to ensure that this file doesn't exist before I continue. How you programmatically delete a file?
[158 byte] By [JamesP] at [2007-11-17 0:46:59]
# 1 Re: Programmatically deleting a file
Check out the DeleteFile(...) function. e.g.BOOL DeleteFile(
LPCTSTR lpFileName // pointer to name of file to delete
);

Chen Weiye
------------------------
When pursuing your dream, don't forget to enjoy your life...
------------------------
Weiye at 2007-11-10 6:46:20 >
# 2 Re: Programmatically deleting a file
BOOL DeleteFile(LPCTSTR lpFileName);
mac_hua at 2007-11-10 6:47:20 >
# 3 Re: Programmatically deleting a file
To know if a file exists, you can use fopen:

FILE *fp;
if((fp=fopen("nomefile.dat","rb"))!=0)
{
// here the file exists
// and you can delete it
}

Bye.
Marco
Marco Moscato at 2007-11-10 6:48:19 >
# 4 Re: Programmatically deleting a file
...or, yet another way:remove("c:\\myfile.txt");

Don't you love C++?
Michael Bechard at 2007-11-10 6:49:23 >
# 5 Re: Programmatically deleting a file
And another way to check if file exists before deleting it...

CString csFile="c:\\myfile.txt";

if (!_access(csFile,0))
remove(csFile);

hope this helps.

-ed
lv2fly at 2007-11-10 6:50:22 >