JavaScript Tutorial/MS JScript/Folders

Материал из Web эксперт
Перейти к: навигация, поиск

Folders

The Folders collection holds a read-only collection of all the available folders.

Because the Folder object is a collection, the folders can be accessed only by using an Enumerator object.

The properties associated with the Folders collection are listed in the following table.

Item Description Add Allows you to add a folder to the collection Count Returns the number of items in the collection Item Set or return an item for a specified key in a Drives dictionary object



<html>
    <body>
    <script language="JScript">
    <!--
    var fileSysObj = new ActiveXObject("Scripting.FileSystemObject");
    document.write(fileSysObj.Folders.count);
    // End hide-->
    </script>
    </html>


Folders.Add()

Syntax



folderscollection.Add(foldername)


Folders.Count

The Count property returns the number of folders in the collection. Folders are added to this collection by using the Folders.Add() method.



<html>
    <body>
    <script language="JScript">
    <!--
    function get(){
      var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");
      var myFolder = myFileSysObj.GetFolder("c:\\Temp");
      var myFolderCollection = myFolder.SubFolders;
      myFolderCollection.Add("test1");
      myFolderCollection.Add("test2");
      alert(myFolderCollection.Count);
    }
    // End hide-->
    </script>
    Get the count of the c:\temp Folders collection.
    <form name="myForm">
    <input type="Button" value="Get Count" onClick="get()">
    </form>
    </body>
    </html>


Folders.Item

Syntax



folderscollection.Item(foldername)