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

前端之家收集整理的这篇文章主要介绍了flex – openWithDefaultApplication在应用程序文件夹中的文件上失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我尝试打开放置在空中app文件夹内的文件,我只会收到“错误#3000:非法路径名称”.如果文件位于app-folder之外的其他位置,则可以正常工作.
  1. private var file:File = File.documentsDirectory;
  2.  
  3. public function download():void{
  4. var pdfFilter:FileFilter = new FileFilter("PDF Files","*.pdf");
  5. file.browseForOpen("Open",[pdfFilter]);
  6. file.addEventListener(Event.SELECT,fileSelected);
  7. }
  8.  
  9. private function fileSelected(e:Event):void
  10. {
  11. var destination:File = File.applicationDirectory
  12. destination = destination.resolvePath("test.pdf");
  13. /*
  14. //This works,also if the file to copy is placed inside the appfolder
  15. file.copyTo(destination,true);
  16. */
  17.  
  18. /*This Throws me an Error #3000,but ONLY if the file is located in
  19. the App folder*/
  20. file.openWithDefaultApplication();
  21.  
  22. }

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

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

此致,Temo

解决方法

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

Opening files with the default system application

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

所以我这样做:

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

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

猜你在找的Flex相关文章