Dear all
what's the function name in c++ if i want use this function to delete my file
Printable View
Dear all
what's the function name in c++ if i want use this function to delete my file
DeleteFile
I love M$ for this, it's so intuitive. :cool:Quote:
Originally Posted by GCDEF
also _wremove()
Kuphryn
that's best oneQuote:
Originally Posted by kuphryn
if( remove( "test.dat" ) == -1 )
perror( "Could not delete 'test.dat'" );
else
printf( "Deleted 'test.dat'\n" );
system("pause");
Well, I would still go for DeleteFile, since it's underlaying WinAPI.
I would use ::SHFileOperation() with FO_DELETE since DeleteFile()/ remove() would fail to delete read only file. :)
CheersCode:SHFILEOPSTRUCT fo={0};
fo.wFunc = FO_DELETE;
fo.pFrom = "C:\\delme.txt";
fo.fFlags = FOF_NOCONFIRMATION|FOF_SILENT;
::SHFileOperation(&fo);
Hehe, the beauty of the IT world: event the simplest problem has 5 solutions that do not work 100% of the time and 1 that works for the time being but you never now in the future. :) These are the moments I feel the IT really makes the world a better place to live. ROFLMAO
:thumb:Quote:
Originally Posted by PadexArt
unlink() - would be another option :)
how about if i want to delete one of folder all file , what's method i can do it
Quote:
Originally Posted by PadexArt
I Love to use WinAPIs DeleteFile..
Hey PadexArt here I got you a more joy..... I got one more solution...
CFile::Remove(fileName)....
;)..
so now will u feel IT makes the BEST place.......
ha ha ha..
Does (or can) the folder contain folders?Quote:
Originally Posted by roger5089
Quote:
Originally Posted by roger5089
go through the below link...
Hope it helps you.
http://www.codeguru.com/forum/showthread.php?t=239271
One more:
Regards,Code:system("del myfile.txt");
Paul McKenzie
No, It is the same as DeleteFile. Just look at the source code:Quote:
Originally Posted by dwurity
:D :DQuote:
Code:void PASCAL CFile::Remove(LPCTSTR lpszFileName)
{
if (!::DeleteFile((LPTSTR)lpszFileName))
CFileException::ThrowOsError((LONG)::GetLastError());
}