Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openWithDefaultApplication fails on files in application folder

I'll ONLY recieve an "Error #3000: Illegal path name" if I try to open a file which is placed inside the app-folder of the air. If the file is somewhere else outside of the app-folder it works.

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();

    }

When i try to get the same file and copy it to another place it's doing fine.

Why that? Something special to do if i wanna open files which are inside the appfolder? It also don't work in debug mode - bin-debug.

Regards, Temo

like image 208
Temo Avatar asked Oct 29 '10 10:10

Temo


1 Answers

After reading the document a few times i saw that this is not possible (it's not a bug, it's a feature!?!)

Opening files with the default system application

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

So I do this instead:

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

Not so nice, but it works.

like image 118
Temo Avatar answered Sep 19 '22 20:09

Temo