Question

Although I have read a few previously answered questions regarding a similar issue, I am not yet clear on how to go ahead. This is the scenario:

I need to delete a few temporary files, but then they are not getting deleted. While debugging i realized that even manually trying to delete the files doesn't delete them. Hence I concluded that some file pointer has not been closed yet preventing me from deleting the file.

But then these file pointers are being used in parts of the code that are not accessible to me. This leaves me with only one solution (maybe), to check if a file pointer is open and delete it.

or is there any other way to handle the situation??

Was it helpful?

Solution

If you're using Windows OS you can use MoveFileEx function.
This allows you do mark a file for deletion after reboot.

MoveFileEx(lpExistingFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top