2010-10-29 173 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

相關問題