VBScript » Objects » Folder

Version: 3.0

The Folder object allows you access and manipulate the various properties of a folder.

Examples

Code:
<%
Dim filesys, demofolder, createdate
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("foldername")
createdate = demofolder.DateCreated
%>
Explanation:

This code uses the GetFolder method of the FileSystemObject object to obtain a Folder object and view one of its properties.

Properties

Attributes

Syntax: object.Attributes [= newattribute]

This property allows us to get or change the various attributes of a file.

DateCreated

Syntax: object.DateCreated

This property gets the date and time that the folder was created. Syntax: object.

DateLastAccessed

Syntax: object.DateLastAccessed

Gets the date and time that the folder was last accessed.

DateLastModified

Syntax: object.DateLastModified

This property gets the date and time that the folder was last modified.

Drive

Syntax: object.Drive

Returns the drive letter of the drive where the folder is located.

Files

Syntax: object.Files

Returns a Files collection consisting of all the File objects in the specified folder.

IsRootFolder

Syntax: object.IsRootFolder

Returns a Boolean value: True if the folder is the root folder, and False otherwise.

Name

Syntax: object.Name

This property lets us get or change the name of the specified folder.

ParentFolder

Syntax: object.ParentFolder

This property gets the parent Folder object relating to the specified folder.

Path

Syntax: object.Path

This property returns a folder's path.

ShortName

Syntax: object.ShortName

Returns the short version of a folder name (using the 8.3 convention). e.g. the folder 'testingshortname' is truncated to 'testin~1'.

ShortPath

Syntax: object.ShortPath

Returns the short version of the folder path (this is the path with any folder and file names truncated as above).

Size

Syntax: object.Size

Returns the size of the specified folder and its contents (in bytes).

SubFolders

Syntax: object.SubFolders

This property returns a Folders collection that consists of all the folders in the specified folder.

Type

Syntax: object.Type

Returns a string containing the folder type description.

Methods

Copy

Syntax: object.Copy destination[, overwrite]

Copies the specified folder from one location to another.

CreateTextFile

Syntax: object.CreateTextFile filename [, overwrite[, unicode]]

This method is used to create a text file and returns a TextStreamObject that can then be used to write to and read from the file.

Delete

Syntax: object.Delete [force]

Deletes the specified folder.

Move

Syntax: object.Move destination

Moves the specified folder from one location to another.

Events

Initialize

See Also: