In our games we have a “camera” that allows players to take photos of clues, i.e. screenshots, these are then saved to the Documents directory. These photos can later be deleted by the player. This works great on iOS, Android, and Mac OSX, however it doesn’t work on Windows.
This can be reproduced with this code ( you’ll need to put an image called “original.png” in the root with main.lua ) :
--Load up an image local original = display.newImage( "original.png" ) original.x = display.contentCenterX original.y = display.contentCenterY -- Save it out display.save( original, "copy.png" ) -- Destroy the image object display.remove( original ) original = nil -- Load up the copy local copy = display.newImage( "copy.png", system.DocumentsDirectory ) copy.x = display.contentCenterX copy.y = display.contentCenterY + 100 -- Destroy the copy display.remove( copy ) copy = nil -- Try to delete it local result, reason = os.remove( system.pathForFile( "copy.png", system.DocumentsDirectory ) ) -- This will most likely fail and have permission denied error print( result, reason)
I’m assuming the permission is denied because something is still holding onto the image file? Or is this a permission I need to give our apps to allow this to work on Windows?