Sometimes you would like to add a file or folder in your Application directory in an AIR project. One of the most common reason is that most developers want to create a file that would be removed later on when the user uninstall their program. The problem is the said directory has a read-only property that results to SecurityError: fileWriteResource.

To solve this, all you need is to create a new File using the said path. That should look like this:

myFile = new File(pathInString);

to get the said path you can use the nativePath property of the File. So that would be:

myFile = new File(File.applicationDirectory.nativePath);

Then you would be able to write files on the application directory.

1 comment :