Hi all,
A tip to write a file into Application directory in AIR
usauly we will get error if we try to write a file like this. Because application directory will be in readonly mode
myFileStream = new FileStream();
var myFile:File = File.applicationDirectory.resolvePath(path);
myFileStream.open(myFile, FileMode.WRITE);
myFileStream.writeUTFBytes(righe);
myFileStream.close();
Error:
SecurityError: fileWriteResource
at runtime::SecurityManager$/checkPrivilegeForCaller()
at flash.filesystem::FileStream/open()
instade of getting resolve path of the application directory and assigning to file object, simply provide application directory path as string .
code is like :
//get application directory path
var appDir:String = File.applicationDirectory.nativePath;
var inFile:File = File(appDir+"abc.txt");
myFileStream = new FileStream();
myFileStream.open(myFile, FileMode.WRITE);
myFileStream.writeUTF(righe);
myFileStream.close();
Happy Flexing..........
No comments:
Post a Comment