- The static properties included in File class :
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:
- var bytearray:ByteArray = new ByteArray();
- var fileToCopy:File = new File("url of file");
- var newFile:File = new File("url of file to be created");
- var fileStream:FileStream = new FileStream();
- fileStream.open(file,FileMode.READ);
- fileStream.readBytes(bytearray);//getting bytes
- var newFileStream :FileStream = new FileStream()
- newFileStream.openAsync( newFile, FileMode.WRITE );
- newFileStream.writeBytes(bytearray);//filling bytes
- 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();
}
{
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:
- NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
- public function onInvokeEvent(invocation:InvokeEvent):void {
- var currentDir:File = invocation.currentDirectory;
- }
- File systems's tutorial:
- Draggout out gesture [Dragging file from air to filesystem]
- Uploading file in air
No comments:
Post a Comment