July 2000
Intermediate to advanced
492 pages
14h 53m
English
ParentFolder (File Object, Folder Object) —
Obj
.ParentFolder
Returns a Folder object representing the folder in which the file or folder is located. This is a read-only property.
None
The following code demonstrates the use of the ParentFolder property when used with a File object and then with a Folder object. Note that, because Name is the default property of a Folder object, the code in the ASP page appears to treat the value returned by the ParentFolder property as a string.
<%
' Dimension local variables.
Dim fsoObject ' FileSystemObject
Dim filObject ' File Object
Dim fdrObject ' Folder Object
Dim strFileParent ' Parent folder of file object
Dim strFolderParent ' Parent folder of folder object
' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
"Scripting.FileSystemObject")
' Using the GetFile method of fsoObject, initialize the
' File object.
Set filObject = fsoObject.GetFile("d:\docs\test.txt")
' Retrieve the name of the folder containing the file Test.TXT.
' In this example, the value of strFileParent is "docs".
strFileParent = filObject.ParentFolder
' Using the GetFolder method of fsoObject, initialize
' the Folder object.
Set fdrObject = fsoObject.GetFolder("d:\mystuff\docs")
' Retrieve the name of the folder that contains the
' folder "docs". In this example, the value of
' strFileParent is "mystuff".
strFolderParent = fdrObject.ParentFolder
. . . [additional code]
%>Read now
Unlock full access