SecurityError: fileWriteResource 此错误发生在: This error occured when i tried to write in a file which was in my applicationDirectory. (此错误发生在当在应用程序目录下写文件时)。
当在 applicationDirectory (应用程序)目录下进行 复制文件时就会出现:SecurityError: fileWriteResource 。
出现此错误的例子:
private function copyToDir():void{
var sourceFile:File=File.applicationDirectory.resolvePath("images/img01.png");
var destination:File=File.applicationDirectory.resolvePath("test.png");
try {
sourceFile.copyTo(destination,true);
} catch(error:IOError) {
trace("IOError:",error.errorID," ",error.message);
}catch(e:Error){
trace("Error:",error.message);
}
}
出现:SecurityError: fileWriteResource 错误
解决方法:
根据 目标目录的绝对地址创建一个绝对地址的 File 再进行复制操作。
例子:
private function copyToDir():void{
var sourceFile:File=File.applicationDirectory.resolvePath("images/img01.png");
var rootDir:File = File.applicationDirectory;
var destination:File=new File(rootDir.nativePath+"/test.png");
if(sourceFile.exists){
trace("sourceFile存在:",sourceFile.nativePath);
}
try {
sourceFile.copyTo(destination,true);
} catch(error:IOError) {
trace("IOError:",error.errorID," ",error.message);
} catch(e:Error){
trace("Error:",e.message);
}
}
结果 :成功.
----------------------------------------------------------------------------------------------------------------------------------
另外写文件的例子:
var applicationDirectoryPath:File = File.applicationDirectory;
var nativePathToApplicationDirectory:String = applicationDirectoryPath.nativePath.toString();
nativePathToApplicationDirectory+= "/my-config.mxml";
var file:File = new File(nativePathToApplicationDirectory);
var filestream:FileStream = new FileStream();
filestream.open(file, FileMode.WRITE);
filestream.writeUTFBytes("My Text");
filestream.close();
分享到:
相关推荐
NetBackup AIR 自动映像复制操作手册,详细的操作步骤及截图。
简单的文件读写程序,适合新手学习。可对导入的文本文件进行修改再导出
这是一个Installer文件,安装的是AdobeAIR软件。使用此软件可以使得air文件轻松安装。
构建 ADOBE® AIR® 应用程序 目录 第 1 章: Adobe AIR 简介 第 2 章: Adobe AIR 安装 安装 Adobe AIR 删除 Adobe AIR 安装和运行 AIR 范例应用程序 Adobe AIR 更新 第 3 章: 使用 AIR API 特定于 AIR 的 ...
小米笔记本Air 13EFI文件
air 模拟普通网页的multipart/form-data提交方式,实现本地文件上传到远程服务器。本例没有服务端获取的解析代码,需要下载的朋友自己简单实现。
flash air的一个小实例,选中一个文件,调用本地系统中默认文件关联程序打开。
用Adobe AIR Runtime程序来打开AIR文件。讲解一下具体的打开AIR文件的方法
of air-to-ground wireless services. These applications include the rapid recovery of damaged terrestrial wireless infrastructure due to a natural disaster, as well as the fulfillment of sudden ...
Instabilities of Regression Estimates Relating Air Pollution to Mortality
SandboxBrowser一个简单的iOS沙箱文件浏览器,您可以通过AirDrop共享文件
flashair电脑版可通过无线LAN在电脑网络驱动器上查看FlashAir里的文件。可以选择数个照片或文件在电脑上读取,也可以同时在电脑上读取所有内容。 flashairtool安装方法: 双击下载好的“FlashAir.exe”文件,将...
在自己电脑上安装了这个才能运行air文件,供急需时用
AirPrint无线打印技术当前仅面向Mac开放,并且只能在几款惠普打印机上实现。没有这些AirPrint兼容打印机的可以借助一款名为Printopia的Mac程序激活AirPrint功能,那么Windows用户呢?想在PC上启用AirPrint的Windows...
serve static files in the air 在线解析压缩合并Less,打包压缩Javascript. 安装 npm install airs -g 或 yarn global add airs 使用 直接执行air启动http server air -p 9090 指定端口 air -d /tmp/ 指定根目录 ...
微博AIR是基于Adobe AIR平台的新浪微博桌面客户端 【使用方法】第一步:安装 Adobe AIR 运行环境(已安装的用户请跳过)http://down.chinaz.com/soft/29198.htm第二步:安装 微博AIR 客户端(解压后运行.air文件) ...
如果你有台iPhone手机, 或者苹果iPad平板电脑,那么你可以很方便得利用苹果iOS系统内置AirPrint功能WiFi无线打印照片,Word,PDF等各种文件到你的Air Printer打印机,但有个前提是你的打印机必须支持苹果Air Print...
和winodw系统的文件管理操作方式相像
The goal of these exercises was to examine a concept then known as the Air-Directed Surface-to-Air Missile (ADSAM) System in support of Navy Overland Cruise Missile Defense. A team of analysts and ...
如果你有台iPhone手机, 或者苹果iPad平板电脑,那么你可以很方便得利用苹果iOS系统内置AirPrint功能WiFi无线打印照片,Word,PDF等各种文件到你的Air Printer打印机,但有个前提是你的打印机必须支持苹果Air Print...