ASP Folder



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 the related 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, and then instantiate the Folder object through 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 collection, properties and methods of the Folder object are described as follows:

Collection

Collection Description
FilesReturns a collection of all files in the specified folder.
SubFoldersReturns the collection of all subfolders in the specified folder.

Attributes

AttributesDescription
AttributesSets or returns the specified Properties of the folder.
DateCreated Returns the date and time the specified folder was created.
DateLastAccessedReturns the date and time the specified folder was last accessed.
DateLastModifiedReturns the date and time the specified folder was last modified.
DriveReturns the drive letter of the drive where the specified folder is located.
IsRootFolderReturns true if the folder is the root folder, false otherwise.
NameSet or return the name of the specified folder.
ParentFolderReturns the parent folder of the specified folder.
PathReturns the path to the specified folder.
ShortNameReturns the short name of the specified folder (8.3 naming convention).
ShortPathReturns the short path (8.3 naming convention) of the specified folder.
SizeReturns the size of the specified folder.
TypeReturns the type of the specified folder.

Method

MethodDescription
CopyCopy the specified folder from one location to another.
DeleteDelete the specified folder.
MoveMove the specified folder from one location to another.
CreateTextFileCreates a new text file in the specified folder and returns a TextStream object to access this file.