i want to delete all files in a directory like documents this what i have.Its not working when i just put documents but it deletes the file no problem when i put a specific path.How do i fix this please help its driving me insane!
One way to do this is enumerate the folder by using FindFirstFile(), FindNestFile() and get attributes for the file using GetFileAttributes and check for readonly and use DeleteFile() finction to delete the file.
What is that std::remove() all about???? The only std::remove() I know is this: http://www.cplusplus.com/reference/algorithm/remove/ , and it removes an item from a collection; it has nothing to do with the file system. Is there an obscure std::remove() I know nothing about????
I believe std:remove does NOT remove the elements. Read again.
The relative order of the elements not removed is preserved, while the elements past the new end of range are still valid, although with unspecified values.
I believe it just move the "removed" elements to after the new end of range. To actually physically remove them depend on your data structure. If you use list or vector you can use the list.erase(), vector.erase() member function for the actual physical removal.
This lead to me to guess you will usually use std:remove() in conjunction with the data structure erase member function hand in hand to do a physical removal of elements.