24
The File I/O API
■
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(fol "/" + fileMask, "files");
if (list){
alert(fol " 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(f " contains: " + str);
}
000_DW_API_Print.book Page 24 Wednesday, July 20, 2005 11:58 AM
Summary of Contents for DREAMWEAVER 8-DREAMWEAVER API
Page 1: ...Dreamweaver API Reference...
Page 16: ......
Page 28: ...28 The File I O API...
Page 38: ...38 The HTTP API...
Page 68: ...68 Flash Integration...
Page 100: ...100 The Database API...
Page 116: ...116 The JavaBeans API...
Page 144: ...144 The Source Control Integration API...
Page 146: ......
Page 254: ...254 Workspace...
Page 298: ...298 Site...
Page 354: ...354 Document...
Page 396: ...396 Page Content...
Page 488: ...488 Design...
Page 550: ...550 Code...