Hello Community,
ive got a huge Problem i just cant find a solution for on my own.
im currently making a picturebook app and i have a bar on top containing thumnail screenshots of all the pages of the story. they also have eventlisteners so you can change to the according page by touching it.
my problem now is that if i made some changes to the page and leaving it im taking a screenshot of it by using display.save(). But now it just wont replace the old thumbnail and when i try to delete the old one it says “permission denied” even if i try to delete the image like described here
http://www.coronalabs.com/blog/2012/07/03/properly-removing-objects-and-variables/
my question would be why is that and is there a way to replace/delete the old image with the new one?
here some code from some tests i did:
[lua]local widget = require(“widget”)
– Function: Copy files to device in binary format
local function copyBinaryFile( srcName, srcPath, dstName, dstPath, overwrite )
local pathRead = system.pathForFile( srcName,srcPath )
local file = io.open( pathRead, “rb” )
local imageData = file:read( “*a” )
io.close( file )
local pathWrite = system.pathForFile( dstName,dstPath )
local file = io.open( pathWrite, “wb” )
file:write( imageData )
io.close( file )
file = nil
end
copyBinaryFile( “icon.png”, system.ResourceDirectory, “icon.png”, system.DocumentsDirectory )
button = widget.newButton{
baseDir = system.DocumentsDirectory,
defaultFile = “icon.png”,
width = 20,
height = 20,
left = 100,
top = 100
}
button.defaultFile:removeSelf()
button.defaultFile = nil
results, reason = os.remove(system.pathForFile( “icon.png”, system.DocumentsDirectory ) )
print(reason)[/lua]
i really hopw you guys can help me its giving me a real headache, thanks a lot