Javascript FSO Files Collection
Folder object returned by the GetFolder method of the Javascript FileSystemObject (FSO) provides the access to the Files collection property that returns a collection of items which can be read using javascript Enumerator collection type object. You can pass the Files collection property of to the Enumerator constructor as a parameter that makes it possible to access the items in sequential order using javascript for loop. In the tutorial about Javascript Enumerator object we discussed about the four methods supported by enumerator that enable you to read the items of the associated collection passed to its class constructor. Here we will learn how to create the FileSystemObject and access the Files collection of client’s PC using the folder object returned by the GetFolder method. Javascript Enumerator collection type object does not allow accessing the items directly by passing their index position. It works on pointer mechanism that returns the item at the current pointer position.
Syntax for FSO GetFolder Files Collection
folderObj.Files
Above syntax can be used to retrieve the enumerator type files collection of the specified folder.
Example of Javascript FSO Files Collection
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for folder object returned by GetFolder method
var folderObj = fso.GetFolder("C:\\Temp");
// creates the enumerator types collection of files
var filesCollection = new Enumerator(folderObj.Files);
var fileObj;
for (filesCollection.moveFirst(); !filesCollection.atEnd(); filesCollection.moveNext()) {
fileObj = filesCollection.item();
document.write(fileObj.Name);
document.write("<br />");
}
// Output:
// demo.txt
// textFile.txt
</script>
Continue to next tutorial: Javascript FSO SubFolders Collection to learn how to get the collection of sub directories at the specified location path.

* will not be published
* hint: http://www.example.com