How to disable confirmation for overwriting a file?

I’m using a momentary button with the following line of code:

system.print.printToImage(event.source.parent, “Screen.jpg”)

And then emailing the saved screenshot out, however a confirmation box opens to ask if the user is sure they want to overwrite the previous file. I want to disable this, and make it so when the button is clicked the image automatically overwrites.

If the user clicks no, an email is sent with the old image instead of updating the the current image. If disabling the confirmation is not possible, is it possible to only allow the email to be sent if a new file is saved?

You need to use a combination of system.print.createImage() and system.file.writeFile()