Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 15.6 ('Green Screen Saver')
Instant purchase and download via GumRoad!


Delete It!

Delete that pesky file or folder that's being stubborn

Issue: 15.6 (November/December 2017)
Author: Sam Rowlands
Author Bio: Sam is a pixelMancer and codeWeaver at Ohanaware.
Article Description: n>No description availabl
Article Length (in bytes): 15,463
Starting Page Number: r>
Article Number: 15603
Related Link(s): None

Excerpt of article text...

Deleting files and folders should be an easy task right? Call folderitem.delete and the job's done.

Yes, that's the principle, but as more and more background system daemons prod, poke, inspect and sometimes open the files as you're working on them, folderitem.delete can fail. I suspect that a common cause of this is to do with how Apple's APIs work.

For instance, if you're reading an image file, it's not closed until you explicitly destroy the object that's reading the file, which leads me to believe that many of Apple's modern daemons encounter an error and just abandon the routine, leaving the file handler still open.

Then, there are folders. These need to have all the files deleted first, and if one of those files is in use by an annoying background task, you can't delete that folder.

What about offering the user the option of being able to recover the file from the Trash?

After working with video and finding that these often get tied up by system daemons ("Exporting failed because it couldn't replace or delete the specified file."), I got fed up and decided I was going to create a single function that I could use to obliterate files when I needed to do so.

...End of Excerpt. Please purchase the magazine to read the full article.