Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AIR Delete File?

Guest
Oct 13, 2011 Oct 13, 2011

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.

TOPICS
ActionScript
5.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Oct 13, 2011 Oct 13, 2011

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.

Translate
Community Expert ,
Oct 13, 2011 Oct 13, 2011

try:

import flash.filesystem.*;

var targetDir:File = targetDir = new File();

var targetFile:File = targetDir.resolvePath("c:/test.txt");

targetFile.deleteFile();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 13, 2011 Oct 13, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2011 Oct 13, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 02, 2016 May 02, 2016
LATEST

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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines