Delete all files in a folder
-
Hello, Can anyone tell me which function I can use to delete all file in a folder. Any standard ANSI C++ function I can used? Thanks!
Nacho
-
Hello, Can anyone tell me which function I can use to delete all file in a folder. Any standard ANSI C++ function I can used? Thanks!
Nacho
There are two solutions; one is to get all the files in the directory using findfirst/findnext and then delete them. The other solution is to use the SHFileOperation. Oh, I suppose you could spawn cmd and delete that way, but it's lame.
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Hello, Can anyone tell me which function I can use to delete all file in a folder. Any standard ANSI C++ function I can used? Thanks!
Nacho
Nacho Chip wrote:
Any standard ANSI C++ function I can used?
No. This type of operation will be OS dependent, and will be very different on each system. For Windows, you can use the FindFile API or the Shell interfaces to accomplish this.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Hello, Can anyone tell me which function I can use to delete all file in a folder. Any standard ANSI C++ function I can used? Thanks!
Nacho
See
WIN32_FIND_DATA find; SetCurrentDirectory("c:\\temp"); HANDLE handle=FindFirstFile("*.*",&find); while(FindNextFile(handle,&find)!=0) DeleteFile(find.cFileName); or you can use from //SHFileOperation(...); FindClose(handle);
_**
**_
WhiteSky