Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 为什么file.moveTo(newfile,true)抛出#3003错误?_Actionscript 3_Air - Fatal编程技术网

Actionscript 3 为什么file.moveTo(newfile,true)抛出#3003错误?

Actionscript 3 为什么file.moveTo(newfile,true)抛出#3003错误?,actionscript-3,air,Actionscript 3,Air,使用直接来自adobe的代码作为测试。尝试在本地系统中移动或重命名文件。获取错误#3003:文件或目录不存在 已尝试解析ApplicationStorage Directory、documentDirectory的路径,并将本机路径设置为本地文件夹。我可以在所有位置成功获取DirectoryListing。但我不能移动或重命名文件 在所有目录中创建源文件。尝试使用和不使用目录中创建的目标文件 import flash.filesystem.File; import flash.events.Ev

使用直接来自adobe的代码作为测试。尝试在本地系统中移动或重命名文件。获取错误#3003:文件或目录不存在

已尝试解析ApplicationStorage Directory、documentDirectory的路径,并将本机路径设置为本地文件夹。我可以在所有位置成功获取DirectoryListing。但我不能移动或重命名文件

在所有目录中创建源文件。尝试使用和不使用目录中创建的目标文件

import flash.filesystem.File;
import flash.events.Event;

var sourceFile:File = File.documentsDirectory;
sourceFile = sourceFile.resolvePath("AIR Test/test1.txt");
var destination:File = File.documentsDirectory;
destination = destination.resolvePath("AIR Test/test2.txt");

try  
{
    sourceFile.moveTo(destination, true);
}
catch (error:Error)
{
    trace("Error:" + error.message);
}

我肯定这是我做错了什么,但如果我知道什么是错的,那就该死了。非常感谢您的帮助。

解析后:trace(sourceFile.exists);我认为这是错误的,因此是错误的。你是对的。我没有这样做,因为sourceFile.getDirectoryListing()提供了这些文件。当可以检索文件时,该文件如何“不存在”?有鉴于此,我将resolvePath更改为applicationDirectory并添加了sourceFile。sourceFile.exists现在跟踪true,moveTo抛出错误:FileWriterSource。这是不是说我没有写入目录的权限?你在测试什么操作系统?如果您使用
AIRTest
(任何不带空格的文件夹名称),是否有帮助?移动和重命名应该在
应用程序存储目录
中工作,但我认为
文档目录
有时可能是只读的(因此会询问“您正在测试哪个操作系统”)。无论如何,如果是只读的,那么您需要执行
file.requestPermission并检查
PermissionEvent
的结果@Organia有这样的代码你可以学习:…Windows 10。我实际上修改了Adobe的代码以匹配我的文件夹。没有空间。我将很快调查@Organia代码。非常感谢你的帮助。