Amit Shrestha

adobe air :: File handling

http://xtrace.blogspot.com/2011/09/adobe-air-file-handling.html  [Migrating over here,,so check it for further updates]

http://xtrace.blogspot.com/search/label/air [Check it for further updates in adobe air]

  • The static properties included in File class :

File.applicationStorageDirectory  A unique storage directory unique for each installed AIR application
File.applicationDirectory  Directory where the application is installed and it is read only
File.desktopDirectory  Desktop directory of the User
File.documentsDirectory  Documents directory of the user
File.userDirectory  User Directory

  • saving file:
  1. var bytearray:ByteArray = new ByteArray();
  2. var fileToCopy:File = new File(“url of file”);
  3. var newFile:File = new File(“url of file to be created”);
  4. var fileStream:FileStream = new FileStream();
  5. fileStream.open(file,FileMode.READ);
  6. fileStream.readBytes(bytearray);//getting bytes
  7. var newFileStream :FileStream = new FileStream()
  8. newFileStream.openAsync( newFile, FileMode.WRITE );
  9. newFileStream.writeBytes(bytearray);//filling bytes
  10. newFileStream.close();
  • Updating file

public function update(value:String,url:String,startIndex:int = 0):void
{
var file:File = new File(url);
var fs:FileStream = new FileStream();
fs.open(file,FileMode.UPDATE);
fs.position = startIndex;
fs.writeUTFBytes(value);
fs.close();
}

  • Getting current directory in air:
  1. NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
  2. public function onInvokeEvent(invocation:InvokeEvent):void {
  3.         var currentDir:File = invocation.currentDirectory;
  4. }


  • File systems’s tutorial:

http://labs.adobe.com/wiki/index.php/Apollo:Articles:Apollo_Local_File_System

http://www.flex888.com/296/9-flex-file-upload-examples-visited.html

 

  • Adobe Air: Problem while reading „ and “

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: