2010-10-29 168 views
6

如果我尝试打开置于空中应用程序文件夹内的文件,我将只收到“错误#3000:非法路径名”。如果该文件位于应用程序文件夹之外的其他位置,则该文件起作用。openWithDefaultApplication在应用程序文件夹中的文件中失败

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。

问候,特莫

回答

11

读取文件几次后,我看到了,这是不可能的(这是不是一个错误,这是一个功能!?!)

Opening files with the default system application

你不能对位于应用程序目录中的文件使用openWithDefaultApplication()方法。

所以我这样做,而不是:

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

不是很好,但它的作品。

+1

你是一个救命的人。我正试图弄清楚这个神秘的错误信息。你会认为他们在错误信息中会更有帮助:“呦,对不起,但是你不能在哟应用程序存储目录中打开文件,dawg。”或者是这个效果。 – 2010-11-03 23:53:57

相关问题