rafaochoa
rafaochoa

Reputation: 161

Adobe AIR - reading a file in the same folder outside AIR package

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.

Upvotes: 3

Views: 3070

Answers (2)

Theo
Theo

Reputation: 132862

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).

Upvotes: 1

Feet
Feet

Reputation: 2587

I believe you want to use File.applicationDirectory.

Upvotes: 0

Related Questions