Skip to content
Dec 12 /

Getting the main application directory in Adobe AIR

The following example shows how you can access the folder containing the Adobe AIR application’s installed files by using the static File.applicationDirectory property.

Full code after the jump

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/12/getting-the-main-application-directory-in-adobe-air/ -->
<mx:WindowedApplication name="File_applicationDirectory_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        styleName="plain"
        showStatusBar="false"
        initialize="init();">
 
    <mx:Script>
        <![CDATA[
            import mx.utils.ObjectUtil;
        ]]>
    </mx:Script>
 
    <mx:Form width="100%" height="100%">
        <mx:FormItem label="File.applicationDirectory:" width="100%" height="100%">
            <mx:TextArea id="textArea"
                    text="{ObjectUtil.toString(File.applicationDirectory)}" 
                    editable="false" 
                    width="100%" 
                    height="100%" />
        </mx:FormItem>
    </mx:Form>
 
</mx:WindowedApplication>
(flash.filesystem::File)#0
  creationDate = Wed Dec 10 19:45:07 GMT-0800 2008
  creator = (null)
  data = (null)
  exists = true
  extension = (null)
  icon = (flash.desktop::Icon)#1
    bitmaps = (Array)#2
      ...
  isDirectory = true
  isHidden = false
  isPackage = false
  isSymbolicLink = false
  modificationDate = Fri Dec 12 19:15:05 GMT-0800 2008
  name = "bin-debug"
  nativePath = "C:Documents and SettingspdehaanMy DocumentsFlex Builder 3File_applicationDirectory_testbin-debug"
  parent = (null)
  size = 0
  spaceAvailable = 2500726784
  type = (null)
  url = "app:/"

2 Comments

leave a comment
  1. Tuyen Nguyen / Mar 17 2010

    Excellent work !!! I do like all of your posts.
    Thank you very much for your tutorials.

  2. Stephen Sweetland / Aug 2 2010

    Thanks chap! Really helpful….

Leave a Comment

Spam Protection by WP-SpamFree