0 Replies Latest reply on Mar 23, 2011 5:11 AM by Starlover_jacob

    get list of filenames

    Starlover_jacob Level 1

      Hi,

      I need a simple array with filenames that are inside a given directory.
      so, I have a function getallfilesinfolder(foldername:string):array
      {
      var arr:Array = new Array();

      return arr;
      }

      lets say i have a folder called http://www.mywebsite.com/images/cars/

      inside that cars folder are an x number of images (jpg, png)

      ———
      in air i use this:
      public function getallfilesinfolder(foldername:String):Array
      {
      var filearray:Array=new Array();
      var directory:File = File.applicationDirectory;
      directory = directory.resolvePath(“images/”+foldername+”");
      var contents:Array = directory.getDirectoryListing();
      for (var i:Number = 0; i < contents.length; i++)
      {
      if(contents[i].type==".jpg" ||contents[i].type==".JPG" ||  contents[i].type==".png")                      filearray.push(contents[i].nativePath);
      }
      return filearray;
      }
      ———

       

      I've looked into urlrequest, filereference, filereferencelist.. and i think I'm close.. but i cant figure it out..

       

      How do i get a list of filenames from the server?

       

      Please some help.