as3 AIR 添加或删除ApplicationDirectory目录下文件
AIR的文件目录静态类型有五种:
File.userDirectory //指向用户文件夹
File.documentsDirectory //指向用户文档文件夹
File.desktopDirectory //指向桌面
File.applicationStorageDirectory //指向应用程序存储目录
File.applicationDirectory //应用程序安装目录
applicationDirectory目录下的文件为只读属性,所以直接对applicationDirectory目录下文件进行操作是无效的(除读取),会报安全箱错误
读取文件方法是:
File.applicationDirectory.resolvePath('read.xml');
但为了对applicationDirectory目录下的文件进行操作。可以通过这样的方式来操作,获取file发布原始目录再添加目标路径,如下
var file:File=new File(File.applicationDirectory.nativePath + '/read.xml');
file.deleteFile();
读取文件,如果没有该文件,自动创建,只读属性目录路径除外,需特殊如上面的操作
var file:File =File.documentsDirectory.resolvePath("HelloWorld.txt");
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = "Congratulations on AIR Save Path";
stream.writeUTFBytes(str);
stream.close();
解析文件
private var nowWriteNum:uint = 0;
private var stream:FileStream;
private function newFileToApp():void
{
nowWriteNum++;
if (nowWriteNum <= zipNum)
{
var tempNum:uint = nowWriteNum - 1;
if (zipData_arr[tempNum][1].split("").splice( -1) == "/")
{
if (!zipData_arr[tempNum][2].exists)
{
zipData_arr[tempNum][2].createDirectory(); newFileToApp();
}
}
else
{
stream= new FileStream();
stream.open(zipData_arr[tempNum][2], FileMode.WRITE);
stream.addEventListener(Event.COMPLETE, writeComHdl);
stream.writeBytes(zipData_arr[tempNum][0]); }
}else{
trace("写入数据 完毕");
} }
as3 AIR 添加或删除ApplicationDirectory目录下文件的更多相关文章
- php根据修改时间删除指定目录下文件
//$dir-文件地址,$files-存储返回数组,$type-查找文件类型组 public function read_dir($dir,&$files,$type) { if(!is_di ...
- [No000073]C#直接删除指定目录下的所有文件及文件夹(保留目录)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- linux 目录下文件批量植入和删除,按日期打包
linux目录下文件批量植入 [root@greymouster http2]# find /usr/local/http2/htdocs/ -type f|xargs sed -i " ...
- Python批量删除指定目录下的指定类型的文件
Python作为一种脚本语言.其很适合文件级的各种操作.以下的代码能够批量删除指定目录下的所有特定类型(CSV类型)的文件. import sys, csv , operator import os ...
- Java基础---Java---IO流-----File 类、递归、删除一个带内容的目录、列出指定目录下文件夹、FilenameFilte
File 类 用来将文件或者文件夹封装成对象 方便对文件与文件夹进行操作. File对象可以作为参数传递给流的构造函数 流只用操作数据,而封装数据的文件只能用File类 File类常见方法: 1.创建 ...
- [ Windows BAT Script ] 删除某个目录下的所有某类文件
删除某个目录下的所有某类文件 @echo off for /R %%s in (*.txt) do ( echo %%s del %%s ) pause @echo on
- python 删除一个目录下的所有文件
一个目录下有文件,文件夹,文件夹里又有文件.文件夹....用python脚本,实现,递归删除一个目录下的所有文件: 目录结构如下: 其中我们要删除所有文件 代码实现如下: import os CUR_ ...
- linux --> 删除指定目录下所有文件
删除指定目录下所有文件 代码样例: ///////////////////////////////////////////////////// //Name: DeleteFile //Purpose ...
- C# 删除指定目录下的所有文件及文件夹
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
随机推荐
- My Router
新路由 型号:Y1 CPU:单核 链接终端:2 路由系统版本:1.6.6.171.6.9.17 运行时长:0天0小时17分13秒 MAC地址:20:76:93:28:CA:24 LAN口状态 MA ...
- Spring Cloud 入门 之 Feign 篇(三)
原文地址:Spring Cloud 入门 之 Feign 篇(三) 博客地址:http://www.extlight.com 一.前言 在上一篇文章<Spring Cloud 入门 之 Ribb ...
- Angular 4.0 环境搭建
1.安装node 2.angular cli安装 sudo npm install -g @angular/cli 3. 使用ng -v 查看安装结果 4. 创建项目 ng new helloworl ...
- 【python】实例-判断用户输入数字的类型
num=input("please input the num: ") print "the number your input is: "+str(num) ...
- JS 获取时间
function CurentTime() { var now = new Date(); var year = now.getFullYear(); //年 var month = now.getM ...
- MongoDB配置成系统服务(Win)
bin同级目录下创建文件夹data 进入data创建文件夹db和文件夹logs 进入logs创建文件mongo.log 以管理员权限打开cmd,进入mongo的bin目录下执行命令: mongod - ...
- ELK高可用搭建---Elasticsearch配置(1)
########################ElasticSearch#######################环境:192.168.125.200 elasticsearch+logst ...
- 峰Spring4学习(1)HelloWorld
HelloWorld.java: package com.cy.test; public class HelloWorld { public void say(){ System.out.printl ...
- [转]Java 运算符的优先级
Java 运算符的优先级(从高到低) 优先级 描述 运算符 1 括号 ().[] 2 正负号 +.- 3 自增自减,非 ++.--.! 4 乘除,取余 *./.% 5 加减 +.- 6 移位运算 &l ...
- 1116 Come on! Let's C (20 分)
1116 Come on! Let's C (20 分) "Let's C" is a popular and fun programming contest hosted by ...