zoukankan      html  css  js  c++  java
  • 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  但是同样不可写

    故绝对路径无效..

  • 相关阅读:
    What is a Complex Element
    XSD(Schema)教程 [转]
    XML对WEB开发的意义
    System.Xml名称空间下的支持DOM的类型
    C#:XML操作类
    xsl:valueof select="." 什么意思?
    文档对象模型
    XSLT转换XML
    DTCMS添加栏目教程
    win8 Windows Media Player 启动后CPU占用率高(60%左右)的解决办法
  • 原文地址:https://www.cnblogs.com/zhepama/p/3473136.html
Copyright © 2011-2022 走看看