The AIR extensions to Flex include the ability to work with files and directories. AIR applications can access the user's filesystem to create, delete, read, and write files, as well as perform a variety of directory operations such as create, delete, move, list files, and so forth.
In addition, AIR will interact with operating system-specific dialog boxes for picking files, saving files, and browsing directories, giving your AIR application an authentic feel in the user's operating system of choice.
This chapter covers working with files and directories, the native dialog boxes, specific Flex components designed to work with filesystems, and a specific method for encrypting data saved on the user's hard drive.
Most of the
File operations available to AIR are accessed through the
flash.filesystem.File class — everything from listing, copying, moving, and deleting files and directories to working with special operating system directories like the user application. The
File class is a pointer used to represent either a path to a directory or a specific file. Once you're pointing at either a file or directory, you then pass the reference into the rest of the APIs, such as
FileStream for reading a file or
File.getDirectoryListing for listing all the files in a given directory.
As an example, here is a
File object that represents a directory:
var file:File = File.documentsDirectory.resolvePath("My Pictures"); ...