Computers & ProgrammingASPBackend Development

ASP Folder Object

The ASP Folder object is used to access a specified file folder on the web server. As with other objects, the Folder object has properties and methods to help you traverse the directories on the drive, and to get to the target directory of interest, so you can access all the properties of the folder.

To access a target folder, you first need to create an instance of the FileSystemObject object and then instantiate the Folder object through the GetFolder method.

Properties

PropertyDescription
AttributesSets or returns the attributes of the specified folder.
DateCreatedReturns the date and time that the specified folder was created.
DateLastAccessedReturns the date and time that the specified folder was last accessed.
DateLastModifiedReturns the date and time that the specified folder was last modified.
DriveReturns the drive letter of the drive on which the specified folder resides.
IsRootFolderReturns true if the folder is the root folder of the current drive and false if not.
NameSets or returns the name of the specified folder.
ParentFolderReturns the Folder object for the parent folder of the specified folder.
PathReturns the absolute path of the specified folder.
ShortNameReturns the 8.3 name format of the folder.
ShortPathReturns the 8.3 name format of the absolute path of the specified folder.
SizeReturns the size of all files and subfolders contained in the specified folder.
TypeReturns the type of the specified folder if available.

Methods

MethodDescription
CopyCopies the specified folder from one folder to another.
DeleteDeletes the specified folder.
MoveMoves the specified folder from one folder to another.
CreateTextFileCreates a new text file in the specified folder and returns a TextStream object that refers to it.

Examples

In the following example, we will create an instance of the FileSystemObject object and then use the GetFolder method to instantiate the Folder object. Finally, we use the Folder object properties to get the information about the specified Folder. The second example shows how to delete a folder.

<%
Dim objFSO, objDrive
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\temp")
Response.Write("Name: " & objFolder.Name & "<br />")
Response.Write("ShortName: " & objFolder.ShortName & "<br />")
Response.Write("Size: " & objFolder.Size & " bytes <br />")
Response.Write("Type: " & objFolder.Type & "<br />")
Response.Write("Path: " & objFolder.Path & "<br />")
Response.Write("ParentFolder: " & objFolder.ParentFolder & "<br />")
Response.Write("ShortPath: " & objFolder.ShortPath & "<br />")
Response.Write("DateCreated: " & objFolder.DateCreated & "<br />")
Response.Write("DateLastAccessed: " & objFolder.DateLastAccessed & "<br />")
Response.Write("DateLastModified: " & objFolder.DateLastModified)
%>
<%
Dim objFSO,objFolder
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder("c:\temp)
objFolder.Delete
Set objFolder=nothing
Set objFSO=nothing
%>

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top