Skip navigation
Currently Being Moderated

SecurityError: fileWriteResource

Feb 26, 2009 1:24 PM

Hello all, I'm having a little difficulty reading, then writing to a XML file in the applicationDirectory. I can read from it fine, parse the results, close the stream. However, when it comes time to write to the file, I get this error thrown:

SecurityError: fileWriteResource
at runtime::SecurityManager$/checkPrivilegeForCaller()
at flash.filestream::FileStream/open()
... (the rest is my stuff)
 
Replies
  • Currently Being Moderated
    Feb 26, 2009 2:30 PM   in reply to Damon Edwards
    You should not write the application directory.

    -ted
     
    |
    Mark as:
  • Currently Being Moderated
    4. ,
    Mar 3, 2009 11:32 AM   in reply to Damon Edwards
    I am trying to do the same thing. I see now that is it read-only. However, when an AIR application is uninstalled the applicationStorageDirectory is not cleared or removed. I am trying to create a screen that thanks the user upon install, meaning when the app is uninstalled I would need to clear out the memory of it ever being installed. The applicationDirectory is removed, but it isn't writable. HMM, any suggestions guys?

    Thanks!
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 3, 2009 12:17 AM   in reply to Damon Edwards

    The solution is to use a line like

    myFile = new File(pathAsString);
     
    

    so use the File(path) constructor. Then you will be able to write files in the application directory. Solution found at http://exaflood.de/syrotech/air-securityerror-filewriteresource/.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 16, 2010 8:03 PM   in reply to Andreiut

    This does not seem to be working in AIR 2.  Can anyone else confirm this?

     
    |
    Mark as:
  • Chris Campbell
    9,446 posts
    May 4, 2010
    Currently Being Moderated
    Aug 18, 2010 11:54 AM   in reply to losing

    Hi losing,

    Is it possible to get some sample code describing the problem you're running into?  What platforms are you having issues with?

     

    Moved discussion to the Problems and bugs forum.

     

    Thanks,

    Chris

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2011 3:55 AM   in reply to Andreiut

    Thanks.

     

    It works fine.


    Quim

     
    |
    Mark as:
  • Currently Being Moderated
    May 30, 2011 4:19 PM   in reply to tzeng

    ...

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2011 3:48 AM   in reply to Damon Edwards

    Hi, this is how I solved/hacked the problem.

     

     

     

    var filePath:String = "app:/" + FileNames.DATA_COMMENTS_DIR + "/" + fileName;

    var appDirFile:File = new File(filePath);
    var xmlFile:File = new File(appDirFile.nativePath);
    var fileStream:FileStream = new FileStream();
    fileStream.open(xmlFile, FileMode.WRITE);
    fileStream.writeUTFBytes(newXMLStr);
    fileStream.close();
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points