ASP Folder Object

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

Folder object

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

To operate on the Folder object, we need to create an instance of the Folder object through the FileSystemObject object. First, create a FileSystemObject object, and then use the GetFolder method of the FileSystemObject object to instantiate the Folder object.

The following code demonstrates the Folder object by using the GetFolder method of the FileSystemObject object and returns the creation date of the specified file using the DateCreated property:

<%
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/2001 10:01:19 AM

Collection of Folder objects, properties, and methods

Collection

Collection Description
Files Return the collection of all folders in the specified folder.
SubFolders Return the collection of all subfolders in the specified folder.

Attributes

Attributes Description
Attributes Set or return the attributes of the specified folder.
DateCreated Return the date and time when the specified folder was created.
DateLastAccessed Return the date and time when the specified folder was last accessed.
DateLastModified Return the date and time when the specified folder was last modified.
Drive Return the drive letter of the drive where the specified folder is located.
IsRootFolder If the folder is the root folder, return true, otherwise return false.
Name Set or return the name of the specified folder.
ParentFolder Return the parent folder of the specified folder.
Path Return the path of the specified file.
ShortName Return the short name of the specified folder. (8.3 Naming Convention)
ShortPath Return the short path of the specified folder. (8.3 Naming Convention)
Size Return the size of the specified folder.
Type Return the type of the specified folder.

Method

Method Description
Copy Copy the specified folder from one location to another.
Delete Delete the specified folder.
Move Move the specified folder from one location to another.
CreateTextFile Create a new text file in the specified folder and return a TextStream object to access this file.