如果我尝试打开放置在空中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();
不太好,但它的工作原理.