将文件从应用程序目录复制到用户桌面后出现错误#3003

时间:2012-01-16 11:27:10

标签: actionscript-3 air flash-cs5.5

我有一个相当简单的代码将sqlite数据库复制到用户的桌面目录:

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]

我做错了什么?

0 个答案:

没有答案