User Guide
The File I/O API 39
Arguments
folderURL,
{constraint}
• The folderURL argument is the folder for which you want a contents list, which is expressed as
a file:// URL, plus an optional wildcard file mask. Valid wildcards are asterisks (*), which
match one or more characters, and question marks (?), which match a single character.
• The constraint argument, if it is supplied, must be either "files" (return only files) or
"directories" (return only folders). If it is omitted, the function returns files and folders.
Returns
An array of strings that represents the contents of the folder.
Example
The following code gets a list of all the text (TXT) files in the C:/temp folder and displays the list
in an alert message:
var folderURL = "file:///c|/temp";
var fileMask = "*.txt";
var list = DWfile.listFolder(folderURL + "/" + fileMask, "files");
if (list){
alert(folderURL + " contains: " + list.join("\n"));
}
DWfile.read()
Availability
Dreamweaver 2.
Description
This function reads the contents of the specified file into a string.
Arguments
fileURL
• The fileURL argument, which is expressed as a file:// URL, is the file you want to read.
Returns
A string that contains the contents of the file or a null value if the read fails.
Example
The following code reads the mydata.txt file and, if it is successful, displays an alert message with
the contents of the file:
var fileURL = "file:///c|/temp/mydata.txt";
var str = DWfile.read(fileURL);
if (str){
alert(fileURL + " contains: " + str);
}
000_DW_API_Print.book Page 39 Wednesday, August 20, 2003 9:14 AM