Actionscript 3 如何在AdobeAIR中获取文件的全名?

Actionscript 3 如何在AdobeAIR中获取文件的全名?,actionscript-3,adobe,air,flash-cs3,Actionscript 3,Adobe,Air,Flash Cs3,我用这样的东西在空中浏览文件。我可以得到文件名,但我需要的是文件的全名。有办法吗 var file:FileReference = new FileReference(); file.addEventListener(Event.SELECT, selectHandler); file.browse(); private function selectHandler(e:Event):void{ file.removeEventListener(Event.SELECT, selectH

我用这样的东西在空中浏览文件。我可以得到文件名,但我需要的是文件的全名。有办法吗

var file:FileReference = new FileReference(); 
file.addEventListener(Event.SELECT, selectHandler); 
file.browse();

private function selectHandler(e:Event):void{ 
file.removeEventListener(Event.SELECT, selectHandler); 
var name = file.name; 
}

您正在使用Flex Builder吗?我会在处理程序中设置一个中断,看看有什么可用。“name”属性适合获取磁盘上的文件名,因此我不知道您的情况有什么问题。

我不是air专家,但是file.nativePath如何?

我不确定
FileReference
是否可以为您提供所选文件的绝对路径。因此,我建议您使用
File
nativePath
属性,而不是
FileReference

var file:File = File.userDirectory;
file.addEventListener(Event.SELECT, selectHandler);
file.browse();

private function selectHandler(e:Event):void{
file.removeEventListener(Event.SELECT, selectHandler);
var filePath:String= file.nativePath;
}

顺便说一下,正如您在我的标记中看到的,我使用的是Flash CS3。FileReference类没有nativePath属性。name只提供文件名和其他属性,但没有提供完整的本机路径。dang,我使用了错误的类。使用File而不是FileReference就可以了。谢谢你,伙计!