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
Property | Description |
---|---|
Attributes | Sets or returns the attributes of the specified folder. |
DateCreated | Returns the date and time that the specified folder was created. |
DateLastAccessed | Returns the date and time that the specified folder was last accessed. |
DateLastModified | Returns the date and time that the specified folder was last modified. |
Drive | Returns the drive letter of the drive on which the specified folder resides. |
IsRootFolder | Returns true if the folder is the root folder of the current drive and false if not. |
Name | Sets or returns the name of the specified folder. |
ParentFolder | Returns the Folder object for the parent folder of the specified folder. |
Path | Returns the absolute path of the specified folder. |
ShortName | Returns the 8.3 name format of the folder. |
ShortPath | Returns the 8.3 name format of the absolute path of the specified folder. |
Size | Returns the size of all files and subfolders contained in the specified folder. |
Type | Returns the type of the specified folder if available. |
Methods
Method | Description |
---|---|
Copy | Copies the specified folder from one folder to another. |
Delete | Deletes the specified folder. |
Move | Moves the specified folder from one folder to another. |
CreateTextFile | Creates 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
%>