views:

16

answers:

1

Hello

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

+1  A: 

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.

Temo