Setting the root directory on a FileSystemTree control in Adobe AIR

by Peter deHaan on December 13, 2008 · 3 comments

in FileSystemTree

The following example shows how you can set the initial directory for the Adobe AIR FileSystemTree control by setting the directory property to a File object, which in this case is the user’s document’s directory.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2008/12/13/setting-the-root-directory-on-a-filesystemtree-control-in-adobe-air/ -->
<mx:WindowedApplication name="FileSystemTree_directory_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        title="{tree.directory.nativePath}">
 
    <mx:FileSystemTree id="tree"
            directory="{File.documentsDirectory}"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>

{ 3 comments… read them below or add one }

1 zmart 01.14.09 at 3:07 am

Hi Peter,

I am trying to set the custom directory, let’s say “C:\Work”.
Still trying :(
I was wondering if you give me some advice how to do that.
Thanks.

Code below doesn’t work properly

[Bindable] private var workDir:File;
workDir = File("C:\Work");
<mx:FileSystemTree id="fsTree" directory="{workDir}" width="574" height="144">
2 zmart 01.14.09 at 12:07 pm

The solution is found:

workDir = new File("file:///C:/Work");  // was workDir = File("C:/Work");
3 Roxy 07.20.09 at 4:28 am

Hi,