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

I am using something like this to find a file in AIR. I can get the filename, but I need the full filename. Is there a way to do this?

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

      

0


a source to share


3 answers


I'm not sure what FileReference

can provide you with the absolute path to the file of your choice. So I suggest you use the property nativePath

File

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

      

+1


a source


Are you using Flex Builder? I would take a break in the handler and see what is available. the "name" property is correct to get the filename as it is on disk, although I don't know what the problem is in your situation.



0


a source


I'm not an air expert, but what about file.nativePath?

0


a source







All Articles