O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.2. Working with the File System

AIR has made it easy to work with the local file system of the client machine. Once an application is installed and has the required permissions, then creating, updating, moving, and deleting files or directories is done through an API. This is an important fact since, because the commands are issued through an API, the AIR runtime ensures that the file system change requests will work on whatever operating system/version the application is installed on.

8.2.1. Directories

The following examples demonstrate how to use the File API to make changes to the file system. These examples use the flash.filesystem.File class for interactions with the file system. The next group of samples will work with the same project and build on it with each new piece of functionality. To get started, create a new AIR project and name it Chapter8_Dir. You should now have an empty file named Chapter8_Dir.mxml that looks like Listing 8-1. Please note that the completed source code for Chapter8_Dir.mxml is available in Listing 8-3.

Example 8-1. Empty Chapter8_Dir.mxml file used for the next set of examples
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute">

</mx:WindowedApplication>
8.2.1.1. Creating a Directory

The first set of functionality that we will explore will be the creation of a new directory. To create a new directory, you must first add an <mx:Script> block to the Chapter8_Dir.mxml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required