BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Archive for October 31st, 2010

Reading File names inside a folder in Adobe AIR

Posted by shardulbartwal on October 31, 2010

Reading the file names(including the folder names) in adobe air is a straight forward task.You have to decide the folder location i.e. desktop,document or application folder etc. And then you can get the file listing of that folder very easily. As I have done for a folder which is on my desktop.Below is code for the same.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	creationComplete="getFolder()">
	<mx:Script>
		<![CDATA[
			private function getFolder() : void
			{
				var dir : File = File.desktopDirectory.resolvePath("MyFolder");
				dir.getDirectoryListingAsync();
				dir.addEventListener(FileListEvent.DIRECTORY_LISTING,onDirectoryListComplete);
			}

			private function onDirectoryListComplete(event : FileListEvent) : void
			{
				var cont : Array = event.files;
				for (var i : uint = 0;i<cont.length;i++)
				{
					trace(cont[i].name + "....." + cont[i].size);
				}
			}
			
		]]>
	</mx:Script>
	
</mx:WindowedApplication>

Posted in AIR | 5 Comments »

 
Follow

Get every new post delivered to your Inbox.