1

我有这个相当简单的代码来将 sqlite db 复制到用户的桌面目录:

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);

该文件存在并且目录“res”存在于用户的桌面上。不幸的是,我收到了这个错误:

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

我究竟做错了什么?

4

0 回答 0