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

SecurityError: fileWriteResource

Guru ,
Feb 26, 2009 Feb 26, 2009
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
22.7K
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
Guru ,
Feb 26, 2009 Feb 26, 2009
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.
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
Adobe Employee ,
Feb 26, 2009 Feb 26, 2009
You should not write the application directory.

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

...

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
Guru ,
Feb 26, 2009 Feb 26, 2009
As I expected. Thanks Ted.
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
New Here ,
Jul 03, 2009 Jul 03, 2009

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

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

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

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

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

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

Thanks.

It works fine.


Quim

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
Mar 03, 2009 Mar 03, 2009
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!
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 ,
Sep 06, 2011 Sep 06, 2011
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();
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