In Python I want to delete an image if it exists before I save the image with the only goal to update the creation date of the file. A small example of the code that generates the problem:
img = QtGui.QImage(filePath)
os.remove(filePath)
img.save(filePath)
This example is not exactly what I am using but when executing this the newly saved image has the creation date of the file that has just been deleted. When I put a delay between the os.remove and img.save it doesn't help (tried up to 3 seconds) but when I do a QMessagebox then the new file will actually get an updated creation date.
Why is this happening and is there anything I can do to get a new creation date on the newly saved file?