Error #3003 after copying file from application directory to user's desktop

3.8k views Asked by At

I've this fairly easy code to copy a sqlite db to the desktop directory of the user:

function copyFile(e:MouseEvent):void
{
    var dbFile = new File(File.applicationDirectory.nativePath);
    dbFile = dbFile.resolvePath("userDB.sqlite");
    trace(dbFile); // [object File] 
    //
    var destination = File.desktopDirectory;
    destination = destination.resolvePath("res");
    trace(destination);// [object File] 
    //
    dbFile.addEventListener(Event.COMPLETE, fileMoveCompleteHandler);
    dbFile.addEventListener(IOErrorEvent.IO_ERROR, fileMoveIOErrorEventHandler);
    dbFile.copyTo(destination, true);
}

function fileMoveCompleteHandler(event)
{
    trace(event.target);
}
function fileMoveIOErrorEventHandler(event)
{
    trace("I/O Error.");
}
//
btn.addEventListener(MouseEvent.MOUSE_DOWN,copyFile);

The file exists and the directory 'res' exists on the user's desktop. Unfortunately I get this error:

Error: Error #3003: File or directory does not exist.
    at flash.filesystem::File/copyTo()
    at dbcopy_fla::MainTimeline/copyFile()[dbcopy_fla.MainTimeline::frame1:48]

What am I doing wrong?

0

There are 0 answers