Reputation: 4006
The following script is used to save a file to the desktop:
var ba:ByteArray = new ByteArray();
ba.writeUTFBytes(xmlData);
var fs : FileStream = new FileStream;
var targetFile : File = File.desktopDirectory.resolvePath('file.xml');
fs.open(targetFile, FileMode.WRITE);
fs.writeBytes(ba);
fs.close();
The file is loaded from the same directory as the swf file. how do I save the file in this directory. The flash file is exported as an Air app
Upvotes: 0
Views: 1239
Reputation: 27506
You can access the folder where the application is installed using File.applicationDirectory
. However, that directory is unfortunately read-only and you can't write to it.
The appropriate place is the File.applicationStorageDirectory
as the documentation says:
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).
Upvotes: 3