• 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  但是同样不可写

    故绝对路径无效..

  • 相关阅读:
    SAP模块
    MVC HtmlHelper 用法
    python篇把python程序打包成apk的完整步骤
    python篇程控电源
    python篇kivy
    CSDN私信太多,如何拉黑,屏蔽,免打扰
    window环境下给centos中配制SSH密钥登录的方法(用winscp上传公钥文件,简单方便)
    日志消息的级别
    Ubuntu2004更换国内源方法
    一文搞定Vue脚手架(vuecli)的安装配置、项目创建及常见错误解决
  • 原文地址:https://www.cnblogs.com/zhepama/p/3473136.html
Copyright © 2020-2023  润新知