Avg. Rating 4.0

Problem

This is not a kind of problem but a code to retrieve the information of particular directory of the system via AIR application using small code.

Solution

In solution i have used the File class to retrieve the inner directory or file information, through which we can get the information like creation-date, extension size etc...

Detailed explanation

 

Below is the sample code in which i have used desktop directory to retrieve information of files and folders information.
 
In mxml i have take datagrid to show all directory information, when File's FileListEvent.DIRECTORY_LISTING occurs it gives a array of all directory listing and whole information.
 
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
 
<mx:Script>
<![CDATA[
private function onBtnClick(event:MouseEvent) : void
{
var dir : File = File.desktopDirectory;
//var dir : File = File.desktopDirectory.resolvePath("path"); if you want fixed path directory information
dir.addEventListener(FileListEvent.DIRECTORY_LISTING,onDirectoryListComplete);
dir.getDirectoryListingAsync();
}
 
private function onDirectoryListComplete(event : FileListEvent) : void
{
var list : Array = event.files;
dgList.dataProvider = list;
}
 
]]>
</mx:Script>
 
<mx:Button label="List" click="onBtnClick(event)" />
 
<mx:DataGrid id="dgList"  height="400" width="950"/>
 
</mx:WindowedApplication>
 
Thanks, Virar Patel

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes