加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex – openWithDefaultApplication在应用程序文件夹中的文件上

发布时间:2020-12-15 02:13:14 所属栏目:百科 来源:网络整理
导读:如果我尝试打开放置在空中app文件夹内的文件,我只会收到“错误#3000:非法路径名称”.如果文件位于app-folder之外的其他位置,则可以正常工作. private var file:File = File.documentsDirectory; public function download():void{ var pdfFilter:FileFilter
如果我尝试打开放置在空中app文件夹内的文件,我只会收到“错误#3000:非法路径名称”.如果文件位于app-folder之外的其他位置,则可以正常工作.
private var file:File = File.documentsDirectory; 

    public function download():void{
        var pdfFilter:FileFilter = new FileFilter("PDF Files","*.pdf"); 
        file.browseForOpen("Open",[pdfFilter]); 
        file.addEventListener(Event.SELECT,fileSelected); 
    }

    private function fileSelected(e:Event):void 
    { 
        var destination:File = File.applicationDirectory
        destination = destination.resolvePath("test.pdf");
        /*
        //This works,also if the file to copy is placed inside the appfolder
        file.copyTo(destination,true);
        */

        /*This Throws me an Error #3000,but ONLY if the file is located in
        the App folder*/
        file.openWithDefaultApplication();

    }

当我尝试获取相同的文件并将其复制到另一个地方时,它做得很好.

为什么?如果我想打开appfolder中的文件,有什么特别的事吗?
它也不能在调试模式下工作 – bin-debug.

此致,Temo

解决方法

几次阅读文档后,我发现这是不可能的(这不是一个错误,它是一个功能!?!)

Opening files with the default system application

You cannot use the openWithDefaultApplication() method with files located in the application directory.

所以我这样做:

file.copyTo(tempFile);
tempFile.openWithDefaultApplication();

不太好,但它的工作原理.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读