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

SecurityError: fileWriteResource

Guru ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

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)
TOPICS
Performance issues

Views

22.4K

Translate

Translate

Report

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
Guru ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

ahh, the application directory is read only. so, i'm assuming that goes for any child directories as well? The file I'm trying to read-write to is a file I've included in the packaging of the application. It's not in the same directory as the application, but one folder down, in a folder call "security". I must be assuming correctly that these are read only as well, and that I should be using applicationStorageDirectory instead?

That'll work, but sucks because being able to include a default file saves time coding since I don't have to write the logic to check if it exists first, then create if doesn't, and so on.

Votes

Translate

Translate

Report

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
Adobe Employee ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

You should not write the application directory.

-ted

Votes

Translate

Translate

Report

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
New Here ,
May 30, 2011 May 30, 2011

Copy link to clipboard

Copied

...

Votes

Translate

Translate

Report

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
Guru ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

As I expected. Thanks Ted.

Votes

Translate

Translate

Report

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
New Here ,
Jul 03, 2009 Jul 03, 2009

Copy link to clipboard

Copied

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/.

Votes

Translate

Translate

Report

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
New Here ,
Aug 16, 2010 Aug 16, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Adobe Employee ,
Aug 18, 2010 Aug 18, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
New Here ,
Feb 21, 2011 Feb 21, 2011

Copy link to clipboard

Copied

Thanks.

It works fine.


Quim

Votes

Translate

Translate

Report

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
Mar 03, 2009 Mar 03, 2009

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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 ,
Sep 06, 2011 Sep 06, 2011

Copy link to clipboard

Copied

LATEST

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();

Votes

Translate

Translate

Report

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