1 Reply Latest reply on Jul 13, 2011 2:53 PM by blazejewicz

    Save XML file error permission


      Hi everyone,


      I read a XML file, edit it and save again:


                      var filePath:String = File.applicationDirectory.resolvePath("alerts.xml").nativePath;
                      var file:File = new File(filePath);


                     var fs:FileStream = new FileStream();
                      fs.open(file, FileMode.READ);
                      fs.addEventListener(IOErrorEvent.IO_ERROR, editsettings_IOError);
                      var xml:XML = XML(fs.readUTFBytes(fs.bytesAvailable));
                      fs.open(file, FileMode.WRITE);
                      xml[key] = value;


      When I´m in debug mode, everything is fine, but when I generate a Executable installer (native installer), it doesn´t work.

      I don´t have permission.


      Any solution?

        • 1. Re: Save XML file error permission
          blazejewicz Level 4



          That's explicitely marked in documentation to not use "applicationDirectory" for write (updates/modification/deletion/etc), e.g.:

          The File class includes static properties that let you reference commonly used directory locations. These static properties include:

          File.applicationStorageDirectory—a storage directory unique to each installed AIR application

          File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)

          and later on the same page:

          Modifying content in the application directory is a bad practice, for security reasons, and is blocked by the operating system on some platforms. If you want to store application-specific data, consider using the application storage directory (File.applicationStorageDirectory).

          http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml#applicationDirectory

          So as pointed in docs you could use applicationStorageDirectory as location where you application-specific content is to be stored/created/updated/written/etc.

          (otherwise everything works fine when running local ADT/debug session - but it could fail at any time when deployed)



          kind regards,