Chapter 9. File System Integration

One of the main benefits of developing applications for the Adobe AIR runtime rather than Flash Player through a browser is that the security sandbox restrictions placed on the browser-based Flash Player do not exist within AIR applications. AIR applications are installed on the desktop with full permissions to access the operating system’s file system.

This means your applications have the ability to read, write, move, and delete files. With this ability comes additional responsibility, because it would be very easy to cause damage or even render a machine inoperable. Therefore, this chapter will show you how to safely work with the file system.

Accessing Directory Aliases in the File Class

Problem

You want to access a user’s Documents directory but don’t want to have to prompt the user to find out where the directory is located or which system the user has.

Solution

Read the userDirectory property within the File class to determine the path to the Documents directory. AIR has already accounted for these differences between operating systems.

Discussion

AIR has several aliases as part of the File class that hold information about the user’s system, including one called userDirectory, which is a reference to the user’s home or Documents directory. Using these aliases is simple and also extremely powerful because it gives you an easy way to make your application work with many operating systems without having to specifically code for each.

In addition to ...

Get Adobe AIR 1.5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.