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

发布于 2024-12-27 01:06:37 字数 1058 浏览 2 评论 0原文

我有一个相当简单的代码来将 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]

我做错了什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文