views:

1178

answers:

2

How may I know File.nativepath from the folder that my .app or .exe AIR app is running? When I try this I just get

'/Users/MYNAME/Desktop/MYAPP/Contents/Resources/FILETHATINEED.xml'

I need put this on any folder and read a xml file in the same folder. I don't need my xml file inside the package.

I need this structure

/folder/AIRAPP.exe

/folder/FILE.xml

Thanx in advance.

A: 

I believe you want to use File.applicationDirectory.

Feet
No, I'm using > File.applicationDirectory.resolvePath('FILE.xml');and I get > '/Users/<MYNAME>/Desktop/<MYAPP>.app/Contents/Resources/FILE.xml'I have my app in the desktop but I need my app Portable I want to use it in any folder and read that content folder.
rafaelochoa
+1  A: 

From what I can find there is no way to get that without doing some work yourself. If we assume that the File.applicationDirectory points to the wrong place only on Mac (which seems like the case), we can do this:

var appDir = File.applicationDirectory

if ( appDir.resolvePath("../../Contents/MacOS").exists ) {
  appDir = appDir.resolvePath("../../..");
}

That is, check if the parent directories of the app directory match the Mac .app bundle directory structure, and in that case use the parent's parent's parent (which should then be the directory containing the .app bundle).

Theo