Chapter 8. Using the Filesystem

One of the most useful features in AIR is the ability to work with the local filesystem. Unlike the Flash Player, whose security model is appropriately much stricter and prohibits writing and manipulating files both server side and client side directly, AIR has the ability to interact directly with files.

You can perform some simple tasks using the filesystem, including using configuration files, using log files to record errors and events, inspecting directories and files, and storing user specific data. The filesystem package offers the ability to provide an application with more complex tasks, such as generating files based on user interactions. This opens the door for the development of applications like word processors, sound editors, image editors, and a whole host of applications yet to be made.

Filesystem Basics

AIR provides a relatively robust set of tools for interacting with the filesystem. These tools are exposed in the class package flash.filesystem, which contains three classes: File, FileStream, and FileMode. Combined, these classes provide features that allow developers to perform tasks such as reading, writing, moving, copying, and deleting files. There are no classes specifically meant for handling directories alone. Because most of the functionality such as copying, moving, deleting, renaming, and creating pertains to files already, the directory handling was rolled into the File handling.

Tip

Use File.isDirectory to differentiate between ...

Get Adobe® AIR™ Bible 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.