I try to save PDF file by creating a temp file then replacing the original.
Since copyfileto fails if the original file exists, I try to delete it first
Using a SaveAsDialog…
dlg.Filter=FileTypes.PDFFiles //defined as a file type in FileTypes1 file type set
if file.exists then
An existing file doesnt get deleted by the delete line, and lasterrorcode = 0
Why would the file not get deleted?
Is it kept alive somehow by the SaveAsDialog?
You should allow some time or use a timer to verify Exists. On Mac, neither delete nor copy is instant.
Its not that.
The file doesnt go even if I dont check for 5 minutes.
The .delete simply fails with no error code.
Its readable, writeable, not locked, owned by me…
I also encountered something strange with the FolderItem. Maybe a new bug in Xojo 2017r1
I will do some more testing with older Xojo versions.
If all else fails, use a shell to rm.
Im using 2015.
2017 has too many problems to upgrade just yet.
2016R3 is fair. Yet, I still use 2015R4.1 for Check Writer production. Could not get it to work adequately in hiDPI mode.
The RM method may come in handy, thanks for that Michel.
But for now I’ve switched back to not creating a temp file and using copyfileto
Instead, I let the OS ask if it is OK to overwrite, and I allow the PDFMBS code to overwrite the existing file in situ.
Im sure I had problems with that method in the past, but it works today.