air写文件 SecurityError: fileWriteResource 时报错的解决方法
用 File.applicationDerectoryPath.resolv("text.txt")会报SecuriyError错误!
解决:
var _Path:File = File.applicationDirectory;
var _url:String = _Path.nativePath.toString();
_url+= "/test.txt";
var file:File = new File(_url);
var stream:FileStream=new FileStream;
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(input.text);
stream.close();
或是
把这句话var file:File =File.applicationDirectory.resolvePath("musiclist.xml");;
改成:var file:File =new File(File.applicationDirectory.resolvePath("musiclist.xml").nativePath);
要将file的文件地址改成全路径的,不能是相对路径的
转:用 File.applicationDerectoryPath.resolv("text.txt")会报SecuriyError错误!
解决:
var _Path:File = File.applicationDirectory;
var _url:String = _Path.nativePath.toString();
_url+= "/test.txt";
var file:File = new File(_url);
var stream:FileStream=new FileStream;
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(input.text);
stream.close();
或是
把这句话var file:File =File.applicationDirectory.resolvePath("musiclist.xml");;
改成:var file:File =new File(File.applicationDirectory.resolvePath("musiclist.xml").nativePath);
要将file的文件地址改成全路径的,不能是相对路径的
用 File.applicationDerectoryPath.resolv("text.txt")会报SecuriyError错误!
解决:
var _Path:File = File.applicationDirectory;
var _url:String = _Path.nativePath.toString();
_url+= "/test.txt";
var file:File = new File(_url);
var stream:FileStream=new FileStream;
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes(input.text);
stream.close();
或是
把这句话var file:File =File.applicationDirectory.resolvePath("musiclist.xml");;
改成:var file:File =new File(File.applicationDirectory.resolvePath("musiclist.xml").nativePath);
要将file的文件地址改成全路径的,不能是相对路径的
此方法不适用于手机平台...
var a:File = File.applicationDirectory.resolvePath("innercity.png");
安卓下:安卓下..a.nativePath为"" url为app:/innercity.png
ios下..a.nativePath为正常 url为app:/innercity.png 但是同样不可写
故绝对路径无效..