FileSystem.getFileList() This page was last modified over 30 day(s) ago and has 2 comment(s)


Back to FileSystem Class Summary

Availability
Windows, Mac OSX, Linux

Usage
mdm.FileSystem.getFileList(folderPath:String, searchMask:String):Array

Parameters
folderPath:String - Path to a folder

searchMask:String - Search mask

Returns
An Array

Description
Returns an array of files which exist in the specified folder and have the specified extension.

Notes
None

Example Code
var myFiles:Array = mdm.FileSystem.getFileList("c:\\", "*.txt");
mdm.Dialogs.prompt(myFiles.toString());

//Other example:
var myFile:Array = mewm.FileSystem.getFileList("C:\\myFolder\\storage\\");
var list:String = myFile.toString().split(",").join("\n");

mdm.FileSystem Class Example Downloads
No Example Downloads Available


User Comment by berandomsen on 23rd May 2012 - 13:15
I need to have a multiple extension search mask, so I'm adding my workaround for anyone interested.
Accepts a comma delimited string like this :
"*.xml,.*.flv"

public function getFiles(url:String, searchMask:String = ""):Array
{

var results:Array = new Array();

if(searchMask.indexOf(",")!=-1)
{
var allFiles:Array= searchMask.split(",").map(function(item:*){
return FileSystem.getFileList(url,item);
}).filter(function(item:*){
return item.length>0; });

for( var i:uint = 0; i < allFiles.length; i++)
{
for( var j:uint = 0; j < allFiles[i].length; j++)
{
results.push(allFiles[i][j]);
}
}

}
else
{
results = FileSystem.getFileList(url,searchMask);
}

return results;
}

User Comment by Jonathan W. on 13th September 2013 - 18:12
You've got a typo in "Other Example" where you call "mewm.FileSystem" instead of "mdm.FileSystem"

Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page