os.remove not deleting files

Hi,

Im using os.remove to delete files from system.DocumentsDirectory in my project. Its an image file
local destDir = system.DocumentsDirectory
local results, reason = os.remove( system.pathForFile(name, destDir )
print(reason)

this is the code name is name of the image file . This does not work and gives me the reason as “Permission denied”

but when i change the name and give “img.jpg” (in the option it deletes the file .

I think the reason may be that the line is taken from a file using

for line in title_file:lines() do
name=line
end
there is only one line in the file i made sure of that

please help

Thank you

[import]uid: 115284 topic_id: 26497 reply_id: 326497[/import]

I am having the same problem deleting a .jpg file.

In the same function I am deleting a .json file and it has no problem. I think it is an issue specific to .jpg files. [import]uid: 191108 topic_id: 26497 reply_id: 139012[/import]

In my case, it turned out to be that the .jpg file was open.

I had a list of buttons that referred to files. Each file had a thumbnail image. If you deleted the file you deleted the thumbnail.

At first the file was being deleted but not the thumbnail and I was getting a permission denied error when I tried to delete the .jpg.

However, I diagnosed the problem by not adding the thumbnail to the button, and os.remove worked as expected. So, check to see that you don’t have the file open before you try to remove it.

Now I’m having some timing problems with removing the icon and then deleting the file. I’m sure I will get it sorted. [import]uid: 191108 topic_id: 26497 reply_id: 139026[/import]

I am having the same problem deleting a .jpg file.

In the same function I am deleting a .json file and it has no problem. I think it is an issue specific to .jpg files. [import]uid: 191108 topic_id: 26497 reply_id: 139012[/import]

In my case, it turned out to be that the .jpg file was open.

I had a list of buttons that referred to files. Each file had a thumbnail image. If you deleted the file you deleted the thumbnail.

At first the file was being deleted but not the thumbnail and I was getting a permission denied error when I tried to delete the .jpg.

However, I diagnosed the problem by not adding the thumbnail to the button, and os.remove worked as expected. So, check to see that you don’t have the file open before you try to remove it.

Now I’m having some timing problems with removing the icon and then deleting the file. I’m sure I will get it sorted. [import]uid: 191108 topic_id: 26497 reply_id: 139026[/import]