Files : Files « MS JScript « JavaScript Tutorial






The Files object represents a collection of files in a folder.

Properties and Methods of the Files Object

Property/MethodDescription
CountReturns the number of items in a collection
ItemSets or returns an item based on a specific key


<html>
    <body>
    <script language="JScript">
    <!--
    function ShowList(foldername)
    {
      var myObject, f, MyFiles, names;
      myObject = new ActiveXObject("Scripting.FileSystemObject");
      f = myObject.GetFolder(foldername);
      myFiles = new Enumerator(f.files);
      names="";
      for (i=0; !myFiles.atEnd(); myFiles.moveNext()){
          names += myFiles.item();
          names += "<br>";
      }
      document.write(names);
    }
    -->
    </script>
    <form name="form1">
    Enter the name of an existing folder including the drive letter.
    <input type="text" size="35" name="file">
    <br><br>
    <input type="Button" value="Get File List" onClick='ShowList(document.form1.file.value)'>
    </form>
    </body>
    </html>








32.10.Files
32.10.1.Files
32.10.2.Files.Count
32.10.3.Files.Item