1 Reply Latest reply on Aug 13, 2009 3:57 PM by adobe_paul

    Application Directory vs. install directory, or identify host platform

    visum Level 1

      I'm building an AIR app that I would like to be configured by a user through an xml file in the same directory as the app, or the app's install directory.  The app:/ way looked promising, not exactly what I'm after.  I want the config file to be in the same directory that a user goes to to invoke the application.  Problem is, this is in different places on each of the three platforms.


      For an application named myApp, printing File.applicationDirectory.nativePath generates the following:

      Mac OS X:  /Applications/myApp.app/Contents/Resources

      Windows: C:\Program Files\myApp

      Ubuntu 9.04: /home/myUser/testapp/myApp/share


      Windows is easy -- File.applicationDirectory returns the place where the .exe actually lives.

      Mac OS X is not so easy.  The user invokes /Applications/myApp.app from the finder, so I'd like the config file to be in /Applications/config.xml, not in the package where the user won't know where it is.

      Linux is a little strange, 'cause I installed the app in /home/myUser/testapp/myApp but I have to dig deeper than that to invoke it.  I'm not too concerned with Linux at this point.


      If there's not a nice way of finding out what the install directory is, is there a way to figure out what the host is (Mac OS, Windows, or Linux) so I can deal with it on a case-by-case basis?




        • 1. Re: Application Directory vs. install directory, or identify host platform
          adobe_paul Adobe Employee

          Is there a particular reason why you specifically want to store the files in the application directory/install directory?


          If the end user doesn't have the appropriate "administrator" rights, he/she won't be able to write files to those directories on some operating systems. In addition, the install directory won't always be predictable on any given OS, since the user can choose to change the installation directory (among other reasons).


          In general it would be safest to pick another directory where it is known that the user has read/write access. In fact, that's what the application storage directory is for -- it's a predictable, user-accessible folder. It is different per-user, so if the machines your app is installed on are commonly used by multiple users, then each user has their own app storage directory.


          The app storage directory can be accessed using the static property File.applicationStorageDirectory or the url form app-storage:/