如果我试图打开一个放在air的app-文件夹中的文件,我只会收到一个"Error #3000:非法路径名“。如果文件在app-folder之外的其他地方,它就可以工作。
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();
}当我尝试获取相同的文件并将其复制到另一个位置时,它做得很好。
为什么呢?如果我想打开are文件夹中的文件,需要做些特殊的事情吗?它也不能在调试模式下工作- bin-debug。
问候你,Temo
发布于 2010-10-29 18:34:53
在阅读了文档几次之后,我发现这是不可能的(这不是一个bug,而是一个特性!?!)
Opening files with the default system application
不能对位于应用程序目录中的文件使用openWithDefaultApplication()方法。
所以我这样做:
file.copyTo(tempFile);
tempFile.openWithDefaultApplication();不是很好,但它是有效的。
https://stackoverflow.com/questions/4050898
复制相似问题