Posted By

allnatural on 12/20/09


Tagged

file FileSystem AIR


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

iamgowan
thastyle


Get all files from a folder


 / Published in: ActionScript 3
 

URL: http://www.destroyyourcomputer.com

Display all files in a folder

  1. import mx.collections.ArrayCollection;
  2. import flash.filesystem.File;
  3.  
  4. //declare array collection 'listfiles' dataprovider for the list//
  5. private var listfiles:ArrayCollection=new ArrayCollection();
  6.  
  7. private function listdesktopfiles():void{
  8.  
  9. //point the file object 'desktop' to the desktop path//
  10.  
  11. var desktop:File = File.desktopDirectory;
  12. /* var desktop:File = File.desktopDirectory.resolvePath("Adobe AIR");
  13. will direct the path to the subdirectory 'Adobe AIR' available on the desktop */
  14.  
  15. //getDirectoryListing() returns array of file objects from the file object pointer, desktop in this case//
  16. var getfiles:Array = desktop.getDirectoryListing();
  17.  
  18. //Push all thi values to the Arraycollection to be diaplayed in the list//
  19. for (var i:int = 0; i < getfiles.length; i++) {
  20. listfiles.addItemAt((getfiles[i].nativePath), i);
  21. }
  22. }

Report this snippet  

You need to login to post a comment.