0

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; 
}
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
rabin
  • 369
  • 5
  • 15

3 Answers3

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;
}
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
  • dang, I was using wrong class. using File instead of FileReference will do. Thanks mate! – rabin May 24 '09 at 05:16
0

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.

Joel Hooks
  • 6,465
  • 4
  • 33
  • 39
0

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