JavaScript Tutorial/MS JScript/Folder

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

Folder

The Folder object provides access to all the properties of a folder.

This object is created by the FileSystemObject.GetFolder().

The folder passed is the name the folder for which you want to create a JScript object.

Method/Property Description Copy() Copies the folder from one location to another Delete() Deletes the specified folder Move() Moves the specified folder Attributes Sets or returns the file system attributes of the folder DateCreated Returns the date the folder was created DateLastAccessed Returns the date the folder was last accessed DateLastModified Returns the date the folder was last modified Drive Returns the drive on which the folder is located Files Returns a Files collection containing all the File objects in the folder IsRootFolder Returns true if the folder is the root folder, false otherwise Name Sets or returns the name of the folder ParentFolder Returns a folder object for the parent folder of the folder Path Returns the path to the folder ShortName Returns the 8.3 version of the name of the folder ShortPath Returns the 8.3 version of the path to the folder Size Returns the byte size of all the contents of the folder SubFolders Returns a Folders collection of all the folders contained in the folder Type Returns the type of folder



   <source lang="javascript">

<html>

   <script language="JScript1.1">
   
   </script>

</html></source>


Folder.Attributes

Syntax



   <source lang="javascript">

folder.Attributes

   folder.Attributes = attrib</source>
   
  

The Attributes property sets or retrieves the attributes of a folder. The following table has the values of the attributes.

Value Stands For Description 0 Normal Normal folder with no attributes set 1 Read Only Read-only folder with read/write attribute 2 Hidden Hidden folder with read/write attribute 4 System System folder with read/write attribute 8 Volume Disk drive volume label with read-only attribute 16 Directory Folder or directory with read-only attribute 32 Archive Folder has changed since last backup with read/write attribute 64 Alias Link or shortcut to a folder with read-only attribute 128 Compressed Compressed folder with read-only attribute

Folder.Copy()

Syntax



   <source lang="javascript">

folder.Copy(destination)

   folder.Copy(destination, boolean)</source>
   
  

Folder.DateCreated

The DateCreated property gets the date when the folder was created.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the date the c:\temp folder was created.
   <form name="myForm">
   <input type="Button" value="Get Date" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.DateLastAccessed

The DateLastAccessed property gets the date the folder was last accessed.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the date the c:\temp folder was last accessed.
   <form name="myForm">
   <input type="Button" value="Get Last Access" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.DateLastModified

The DateLastModified property gets the date the folder was last modified.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the date the c:\temp folder was last modified.
   <form name="myForm">
   <input type="Button" value="Get Last Modified" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.Delete()

Syntax



   <source lang="javascript">

folder.Delete(boolean)

   folder.Delete()</source>
   
  

Folder.Drive

The Drive property returns the drive letter of the folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the drive the c:\temp folder is located on.
   <form name="myForm">
   <input type="Button" value="Get Drive" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.Files

The Files property returns a collection consisting of all the File objects contained in the folder. This includes hidden and system files.



   <source lang="javascript">

<html>

   <script language="JScript1.1">
   
   </script>

</html></source>


Folder.IsRootFolder

The IsRootFolder property evaluates to true if the folder is the root folder, and false otherwise.



   <source lang="javascript">

<html>

   <script language="JScript1.1">
   
   </script>

</html></source>


Folder.Move()

Syntax



   <source lang="javascript">

folder.Move(destination)</source>


Folder.Name

The Name property sets or gets the name of the folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the name of the c:\temp folder.
   <form name="myForm">
   <input type="Button" value="Get Name" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.ParentFolder

The ParentFolder property returns a new Folder object for the parent folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the name of the c:\temp parent folder.
   <form name="myForm">
   <input type="Button" value="Get Parent Folder" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.Path

The Path property returns the full path to the folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JavaScript1.2">
   
   </script>
   Get the path of the c:\temp folder.
   <form name="myForm">
   <input type="Button" value="Get Path" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.ShortName

   <source lang="javascript">

The ShortName property returns the 8.3 name of the folder.

   <html>
   <body>
   <script language="JScript">
   
   </script>
   Get the short name of the "C:\Program Files" folder.
   <form name="myForm">
   <input type="Button" value="Get Short Name" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.ShortPath

The ShortPath property returns the 8.3 path to the folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the short path of the "c:\\Program Files" folder.
   <form name="myForm">
   <input type="Button" value="Get Short Path" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.Size

The Size property returns the byte size of the folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the size of the "c:\\Program Files" folder.
   <form name="myForm">
   <input type="Button" value="Get Size" onClick="get()">
   </form>
   </body>
   </html></source>
   
  

Folder.SubFolders

The SubFolders property returns a collection consisting of all the Folder objects contained in the folder. This includes hidden and system folders.



   <source lang="javascript">

<html>

   <script language="JScript">
   
   </script>

</html></source>


Folder.Type

The Type property returns the type of the folder. For a folder, the return value is File Folder.



   <source lang="javascript">

<html>

   <body>
   <script language="JScript">
   
   </script>
   Get the type of the "c:\\Program Files" folder.
   <form name="myForm">
   <input type="Button" value="Get Type" onClick="get()">
   </form>
   </body>
   </html></source>