The File I/O API > The file I/O API > DWfile.listFolder() |
Availability
Dreamweaver 2.0
Description
Gets a list of the contents of the specified folder.
Arguments
folderURL, {constraint}
| The first argument is the folder for which you want a contents list, expressed as a file:// URL, plus an optional wildcard file mask. Valid wildcards are * (matches 1 or more characters) and ? (matches a single character). | |
The second argument, if supplied, must be either "files" (return only files) or "directories" (return only directories). If omitted, the function returns both files and directories. |
Returns
An array of strings representing the contents of the folder.
Example
The following code gets a list of all the text (.txt) files in the temp folder and displays the list in an alert box.
var folderURL = "file:///c|/temp";
var fileMask = "*.txt";
var list = listFolder(folderURL + "/" + fileMask, "files");
if (list){
alert(folderURL + " contains: " + list.join("\n"));
}