How to delete files?

I have a problem with deleting files.
I’m creating a file via a

CCRender::saveToFile(...);

as a PNG, then I’m trying to delete it with

remove(...)

from <stdio.h>. “Remove” function returns 0, which means that the file did get deleted, and also

CCFileUtils::isFileExist(...)

says that the file is not there.
However, when I try to save the file again, it does not work - as if the first one was still there and could not be overwritten.

Has anyone ever encountered such a problem? Does anyone know how to solve it?

Use platform-specific API. Of course, it’s better to separate it instead of copypasting to a few places.