AIR: File NativePath vs. URL

This would have saved me some time had I read the documentation a little better.

File

When looking at the members of a flash.filesystem.File object, I was initially using “nativePath” to discover the location of the file on a users system.  Knowing that path formatting differs between operating systems, I had a little logic in there to check whether the user was on a Mac or a PC:

var os:String = Capabilities.os.substr(0, 3).toLowerCase();
if(os == "mac"){
	//create a mac-compatible string
}else{
	//create a windows-compatible string
}

This is not necessary, as the “url” property of the File object will provide an OS-agnostic file location string to begin with. The differences can be seen in the screen capture above. in this case, the nativePath is formatted for Windows.

While not a huge time saver in this particular example, every little bit counts!

1 thought on “AIR: File NativePath vs. URL”

Leave a Comment

Your email address will not be published. Required fields are marked *