Deleting an image after using it.

I am using two photo files in display.newImage and want to delete after that but whatever I do doesn’t seem to close the files so I can delete them. I have to assign both to p and delete both after using.

p= display. newImage (“1.png”,system.DocumentsDirectory)
p= display. newImage (“2.png”,system.DocumentsDirectory)

p:removeSelf()
p = nil

f1 = (“1.png”,system.DocumentsDirectory)

f2 = (“2.png”,system.DocumentsDirectory)
os.remove(f1)
os.remove (f2)

This seems to be only an issue in simulator where I use Windows 7.

Hi @amirfarazmand,

When you speak of these files, do you mean the files on your actual computer? Or on the device after the app is built and installed? I can’t vouch that os.remove() works reliably on the actual system/Simulator… I believe it’s intended for real devices. Now, if you’re seeing these results on your actual device, then we may need to investigate further.

Take care,

Brent

Hi Brent, Thanks for the reply. I tested this on the device and it seems fine. However, on the simulator installed on Windows 7 doesn’t delete the files.

Hi @amirfarazmand,

I’m not entirely surprised by this. There could be all sorts of OS-specific reasons (permissions, path references, etc.) why it’s not deleting the files from your local system (Windows machine). The most important thing is that it’s working on real devices. :slight_smile:

Brent

No worries Brent. I get the message access denied. However, I can delete it manually. Windows permission and user access is always messy :slight_smile:

This seems to be only an issue in simulator where I use Windows 7.

Hi @amirfarazmand,

When you speak of these files, do you mean the files on your actual computer? Or on the device after the app is built and installed? I can’t vouch that os.remove() works reliably on the actual system/Simulator… I believe it’s intended for real devices. Now, if you’re seeing these results on your actual device, then we may need to investigate further.

Take care,

Brent

Hi Brent, Thanks for the reply. I tested this on the device and it seems fine. However, on the simulator installed on Windows 7 doesn’t delete the files.

Hi @amirfarazmand,

I’m not entirely surprised by this. There could be all sorts of OS-specific reasons (permissions, path references, etc.) why it’s not deleting the files from your local system (Windows machine). The most important thing is that it’s working on real devices. :slight_smile:

Brent

No worries Brent. I get the message access denied. However, I can delete it manually. Windows permission and user access is always messy :slight_smile: