Working with Files

The class flash.filesystem.File is a means of getting access to the files and directories on the user’s computer. This class enables you to create, move, copy, or delete files. It also comes with generic constants that resolve the path to the user, desktop, or document directories and offer a unified cross-platform way to access application resource files. For read/write operations, use the class FileStream from the package flash.filesystem.

AIR supports working with files in two modes: synchronous and asynchronous. Synchronous mode forces the application to block (wait) until this I/O operation is complete. In asynchronous mode, the user can continue working with the application while it works with files, and an event notification mechanism monitors the progress of the I/O. Those methods that work asynchronously have the suffix Async in their names—for example, File.copyToAsync() or FileStream.openAsync(). Using the asynchronous versions of I/O requires a bit more coding, but it should be your first choice when you need to process files of substantial sizes.

Commonly Used Directories

Because AIR is a cross-platform runtime, it shields the user from knowing specifics of the structure of the native filesystem by introducing predefined alias names for certain directories.

The app:/ alias refers to your application’s root read-only directory, where all files (both code and assets) that you packaged with your application are located. For example, if your application includes ...

Get Agile Enterprise Application Development with Flex 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.