|
-
August 24th, 2006, 10:56 AM
#1
delete file
Dear all
what's the function name in c++ if i want use this function to delete my file
-
August 24th, 2006, 11:03 AM
#2
-
August 24th, 2006, 11:08 AM
#3
Re: delete file
 Originally Posted by GCDEF
DeleteFile
I love M$ for this, it's so intuitive.
Regards,
Ramkrishna Pawar
-
August 24th, 2006, 01:15 PM
#4
-
August 24th, 2006, 09:09 PM
#5
Re: delete file
 Originally Posted by kuphryn
also _wremove()
Kuphryn
that's best one
if( remove( "test.dat" ) == -1 )
perror( "Could not delete 'test.dat'" );
else
printf( "Deleted 'test.dat'\n" );
system("pause");
-
August 25th, 2006, 12:46 AM
#6
Re: delete file
Well, I would still go for DeleteFile, since it's underlaying WinAPI.
-
August 25th, 2006, 03:25 AM
#7
Re: delete file
I would use ::SHFileOperation() with FO_DELETE since DeleteFile()/ remove() would fail to delete read only file. 
Code:
SHFILEOPSTRUCT fo={0};
fo.wFunc = FO_DELETE;
fo.pFrom = "C:\\delme.txt";
fo.fFlags = FOF_NOCONFIRMATION|FOF_SILENT;
::SHFileOperation(&fo);
Cheers
-
August 25th, 2006, 04:02 AM
#8
Re: delete file
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
Har Har
-
August 25th, 2006, 04:15 AM
#9
Re: delete file
 Originally Posted by PadexArt
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

unlink() - would be another option
- Sreehari
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
" Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin
-
August 25th, 2006, 09:43 AM
#10
Re: delete file
how about if i want to delete one of folder all file , what's method i can do it
-
August 25th, 2006, 09:52 AM
#11
Re: delete file
 Originally Posted by PadexArt
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
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..
-
August 25th, 2006, 10:00 AM
#12
Re: delete file
 Originally Posted by roger5089
how about if i want to delete one of folder all file , what's method i can do it
Does (or can) the folder contain folders?
-
August 25th, 2006, 10:02 AM
#13
Re: delete file
 Originally Posted by roger5089
how about if i want to delete one of folder all file , what's method i can do it
go through the below link...
Hope it helps you.
http://www.codeguru.com/forum/showthread.php?t=239271
-
August 25th, 2006, 10:08 AM
#14
Re: delete file
One more:
Code:
system("del myfile.txt");
Regards,
Paul McKenzie
-
August 25th, 2006, 10:18 AM
#15
Re: delete file
 Originally Posted by dwurity
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..
No, It is the same as DeleteFile. Just look at the source code:
Code:
void PASCAL CFile::Remove(LPCTSTR lpszFileName)
{
if (!::DeleteFile((LPTSTR)lpszFileName))
CFileException::ThrowOsError((LONG)::GetLastError());
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|