AIR File Operations (Part 3): Reading and Writing Files with the FileStream Object

Quick Start Examples:Example 1. Reading XML var testXML:XML; var file:File = File.documentsDirectory.resolvePath(“Mousebomb/test.xml”); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.READ); testXML = XML(fileStream.readUTFBytes(fileStream.bytesAvailable)); fileStream.close(); The example uses the readUTFBytes() method to read the content and convert it into an XML object.

Flash

AIR File Operations (Part 2): Using File Objects to Manipulate Files and Directories

What is a File object? A File object is a pointer to a file or directory in the file system. For security reasons, it’s only available in AIR. What can a File object do? Get specific directories, including the user directory, the user documents directory, the directory from which the application was launched, and the application directory Copy files and directories Move files and directories Delete files and directories (or move them to the trash) List the files and directories in a given directory Create temporary files and folders Create directories Read file information Get file system information

Flash

AIR File Operations (Part 1): AIR File Basics

AIR lets us build applications that work with the file system. Using the classes provided by the Adobe® AIR™ file system API, you can access the host’s file system — reading, managing, creating, and deleting directories and files, writing data to files, and more. I’ve broken working with the file system down into three parts of AIR file operations: AIR file basics (below) Using the File object to work with files and directories Using the FileStream object to read and write files Language reference for the relevant classes flash.filesystem.File flash.filesystem.FileStream flash.filesystem.FileMode

Flash