Get all files from a folder


/ Published in: ActionScript 3
Save to your folder(s)

Display all files in a folder


Copy this code and paste it in your HTML
  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. }

URL: http://www.destroyyourcomputer.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.