90 | Chapter 4: AIR Mini-Cookbook
argument is set to false, and a collision occurs, the applica-
tion throws an error:
var move =
air.File.applicationResourceDirectory.resolve( "temp.txt" );
try
{
temp.moveTo( move, false );
}
catch( ioe )
{
alert( "Can't move file:\n" + ioe.message );
}
The JavaScript try/catch block will receive an error object of
typeIOError. The IOErrorclass has numerous properties
available that can be used for further evaluation. The excep-
tion in the previous code snippet raises the error message
that is generated by Adobe AIR:
<html>
<head>
<title>Temporary File</title>
<script type="text/javascript" src="AIRAliases.js"></
script>
<script>
function doLoad( )
{
var stream = new air.FileStream( );
var temp = air.File.createTempFile( );
var move = air.File.applicationResourceDirectory.
resolve( "temp.txt" );
stream.open( temp, air.FileMode.WRITE );
stream.writeMultiByte( "Hello", air.File.systemCharset
);
stream.close( );
try
{
temp.moveTo( move, false );
}