Chapter 45. Local File Management with AIR
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.
File Operations
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.
Referencing Directories
As an example, here is a File
object that represents a directory:
var file:File = File.documentsDirectory.resolvePath("My Pictures"); ...
Get Professional Adobe® Flex® 3 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.