JavaScript Tutorial/MS JScript/Files
Files
The Files object represents a collection of files in a folder.
Properties and Methods of the Files Object
Property/Method Description Count Returns the number of items in a collection Item Sets or returns an item based on a specific key
<source lang="javascript">
<html>
<body> <script language="JScript"> </script> <form name="form1"> Enter the name of an existing folder including the drive letter. <input type="text" size="35" name="file">
<input type="Button" value="Get File List" onClick="ShowList(document.form1.file.value)"> </form> </body> </html></source>
Files.Count
The Count property returns the number of items in the Files collection.
<source lang="javascript">
<html>
<body> <script language="JScript"> </script> <form name="myForm"> Enter the name of a folder which contains files. <input type="text" size="35" name="file">
<input type="Button" value="Get File Count" onClick="getCount(document.form1.file.value)"> </form> </body> </html></source>
Files.Item
The Item property sets or returns an item based on a specified key in a collection of files.
<source lang="javascript">
<html>
<body> <script language="JScript"> </script> <form name="myForm"> Enter the name of a folder which contains files. <input type="text" size="35" name="file">
<input type="Button" value="Get File Item" onClick="getItem(document.form1.file.value)"> </form> </body> </html></source>