ASP FolderObject


The Folder object is used to return information about a specified folder.


Folder Object

The Folder object is used to return information about a specified folder.

To work with the properties and methods of the Folder object, you need to create an instance of the Folder object through the FileSystemObject object. First, create a FileSystemObject object, then instantiate the Folder object via the GetFolder method of the FileSystemObject object.

The following code uses the GetFolder method of the FileSystemObject object to instantiate the Folder object, and uses the DateCreated property to return the creation date of the specified folder:

<%
Dim fs,fo
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set fo=fs.GetFolder("c:\test")
Response.Write("Folder created: " & fo.DateCreated)
set fo=nothing
set fs=nothing
%>

Output:

Folder created: 10/22/2008 10:01:19 AM

The collections, properties, and methods of the Folder object are described below:

Collection

Collection Description
Files Returns a collection of all files in the specified folder.
SubFolders Returns a collection of all subfolders in the specified folder.

Properties

Property Description
Attributes Sets or returns the attributes of the specified folder.
DateCreated Returns the date and time when the specified folder was created.
DateLastAccessed Returns the date and time when the specified folder was last accessed.
DateLastModified Returns the date and time when the specified folder was last modified.
Drive Returns the drive letter of the drive where the specified folder is located.
IsRootFolder Returns true if the folder is a root folder, otherwise returns false.
Name Sets or returns the name of the specified folder.
ParentFolder Returns the parent folder of the specified folder.
Path Returns the path of the specified folder.
ShortName Returns the short name of the specified folder (8.3 naming convention).
ShortPath Returns the short path of the specified folder (8.3 naming convention).
Size Returns the size of the specified folder.
Type Returns the type of the specified folder.

Methods

Method Description
Copy Copies the specified folder from one location to another.
Delete Deletes the specified folder.
Move Moves the specified folder from one location to another.
CreateTextFile Creates a new text file in the specified folder and returns a TextStream object to access this file.

Other Extensions