How do I get the fullname of a file in Adobe AIR?

*爱你&永不变心* 提交于 2019-12-13 03:47:18

问题


I'm using something like this to browse for a file in AIR. I can get the filename, but what I need is the fullname of the file. Is there a way to do that?

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; 
}

回答1:


I am not sure if FileReference can give you the absolute path of the file you selected. So I suggest you to use nativePath property of the File rather than 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;
}



回答2:


Are you using Flex Builder? I'd put a break in the handler and see what is available. the "name" property is proper for getting the filename as it is on disk though, so I don't know what the problem is in your situation.




回答3:


I'm no air expert, but how about file.nativePath ?



来源:https://stackoverflow.com/questions/903080/how-do-i-get-the-fullname-of-a-file-in-adobe-air

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!