Flash
  Home arrow Flash arrow A Closer Look at Apollo`s File System API
IBM Rational Software Development Conference
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

A Closer Look at Apollo`s File System API
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-20

    Table of Contents:
  • A Closer Look at Apollo`s File System API
  • Copying and Moving Files and Directories
  • Reading and Writing Files
  • The open() and openAsync() Methods
  • File Open Modes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Create a Highly Available Database Solution. Advantage Database Server can provide the availability to keep your data safe and ready for your application and users.

    A Closer Look at Apollo`s File System API
    (Page 1 of 5 )

    In this second article in a two-part series devoted to Apollo's file system API, we delve heavily into the intricacies of creating and manipulating files and directories. It is excerpted from chapter four of the Apollo for Adobe Flex Developer's Pocket Guide, written by Mike Chambers, Rob Dixon and Jeff Swartz (O'Reilly, 2007; ISBN: 0596513917). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    Reading Directory Contents

    The File.listDirectory() method returns an array listing ofFileobjects that represent the files and directories contained within the specified directory. For example, the following code lists the contents of the desktop directory:

      var directory:File = File.desktopDirectory;
      var contents:Array = directory.listDirectory();
      for (var i:uint = 0; i < contents.length; i++) {
         
    if (contents[i].isDirectory) {
              trace(contents[i].name);
          } else {
              trace(contents[i].name,
              contents[i].size,
              "bytes");
         
    }
      }

    TheFile.listDirectory()method returns only the root level files and directories in a directory. It does not recursively search through subdirectories for their contents. You can, of course, write code to traverse subdirectories, though if you do so, you might want to use theFile.listDirectoryAsync()method so that other ActionScript-driven processes can continue while the directory listings are being compiled.

    Also see “Getting a Directory Listing” inChapter 5.

    Getting File Information

    The File class includes a number of properties that contain information about a file or directory.

    Property

    Description

    exists

    States whether the file or directory exists. This is worth checking, for example, before you attempt to read, write, copy, or move a file.

    isDirectory

    States whether the Fileobject points to a directory (true) or a file (false). You will want to check this before attempting directory-specific operations (such as the listDirectory() method) or attempting file-specific operations (such as reading a file).

    isHidden

    States whether the file or directory is hidden.

    nativePath

    Notes the operating system-specific path to the file or directory.

    parent

    Notes the parent directory of the File instance.

    url

    Notes the operating system-independent path to the file or directory.

     

    TheFileclass also inherits the following useful properties from theFileReferenceclass:

    Property creationDate

    Description The date the file or folder was created.

    modificationDate

    The date when the file was last modified.

    name

    The file or folder name.

    size

    The size of the file, in bytes.

    More Flash Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Apollo for Adobe Flex Developer's Pocket...
     

    Buy this book now. This article is excerpted from chapter four of the Apollo for Adobe Flex Developer's Pocket Guide, written by Mike Chambers, Rob Dixon and Jeff Swartz (O'Reilly, 2007; ISBN: 0596513917). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders
    - Fun Things to Do with Movie Clips in Flash MX
    - Referencing Movie Clips in Flash MX
    - Organizing Movie Clips in Flash MX
    - Making Movie Clips Perform in Flash MX
    - Video and the Flash Communication Server






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway