Copy link to clipboard
Copied
I am needing to delete a file using AIR (2.7) and keep getting a 3001 error - File or Directory access denied.
Running Win 7, have admin priveleges.
Simple test, just trying to delete a txt file off of c:
import flash.filesystem.*;
var targetDir:File = targetDir = new File("c:/");
var targetFile:File = targetDir.resolvePath("test.txt");
targetFile.deleteFile();
Cross Posted in the AIR forum too, just hoping someone here knows.
Thanks kglad, but that doesn't make any diff. It's a rights issue... I can delete files in my users folder ok, just not elsewhere. The cure is to either run the app as admin, or specifically give the logged in user rights to the folder I need to delete from. Either way, I got it figured out.
Copy link to clipboard
Copied
try:
import flash.filesystem.*;
var targetDir:File = targetDir = new File();
var targetFile:File = targetDir.resolvePath("c:/test.txt");
targetFile.deleteFile();
Copy link to clipboard
Copied
Thanks kglad, but that doesn't make any diff. It's a rights issue... I can delete files in my users folder ok, just not elsewhere. The cure is to either run the app as admin, or specifically give the logged in user rights to the folder I need to delete from. Either way, I got it figured out.
Copy link to clipboard
Copied
interesting. you'd think there would be a prompt to run as admin but i guess an air app is too far divorced from the os to trigger a prompt.
Copy link to clipboard
Copied
Ok sorry to hijack your topic but Adobe isn't letting me start my own today. Its related though. So I have this function:where I am trying to delete a file on an SDCARD of an Android phone. See the function below.

The PhotoLinkFIle is a reference to PhotoLinkFile:File where it got created from a MediaPromise.file conversion. When I try to delete, moveToTrash then i get a 3012 ("Cannot Delete File") error. If I make a temporary file then delete it then it works. So I do have WRITE TO FILE permissions set correctly I think. I have tried deleting files already downloaded, captured with the native camera in android or screenshots taken with the phone. When the application runs it opens the photo gallery. I suspect that since the gallery is open it sees the photo I am trying to delete as open and in use. I cant see where there would be a problem deleting otherwise.
By the way I am trying to do all of this on Animate CC/Flash Professional Actionscript 3.
Any ideas? Is there a permission I missed or setting I need to make to be able to delete files not already created by my script?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more