Using ADO Record to Create and Navigate Intranet Files and Folders - Navigating the files and folders (Page 5 of 6 )
These files and folders can be accessed as easily as they were created. For example the statement rec.Open with the first argument set equal to: "DevHome/ASPFree" would open that folder and the various files added are its children. Hence getChildren will get all the children. The record also has its fields, one of which is ASPFree which happens to be the RESOURCE_PARSENAME. The loop puts out all the record-related information (not that of the children). These are also shown in the comments of the following code listing.
Option Compare Database
Private rec As ADODB.Record
Private chilun2 As ADODB.Record
Private Sub Command0_Click()
Set rec = New ADODB.Record
'open the ASPFREE folder
rec.Open "DevHome/ASPFree", "URL=http://hodentek/"
'count how many fields there are in the folder
MsgBox (rec.Fields.Count)
'print the name, value pair for each field
For i = 0 To rec.Fields.Count - 1
Debug.Print rec.Fields(i).Name & " : " _
& rec.Fields(i).Value
Next i
MsgBox ("rec fields: " & rec.Fields _
("RESOURCE_PARSENAME").Value)
MsgBox ("parentUrl" & rec.ParentURL)
'get the children of this folder
Set chilun = rec.GetChildren
'get all the children
Do Until chilun.EOF
Debug.Print chilun(0) & vbCrLf
chilun.MoveNext
Loop
Debug.Print "--------------------------------------"
End Sub
The result of running this code as it appears in the immediate window is shown in the following paragraph.
RESOURCE_PARSENAME : ASPFree
RESOURCE_PARENTNAME : http://hodentek/DevHome
RESOURCE_ABSOLUTEPARSENAME : http://hodentek/DevHome/ASPFree
RESOURCE_ISHIDDEN :
RESOURCE_ISREADONLY :
RESOURCE_CONTENTTYPE :
RESOURCE_CONTENTCLASS :
RESOURCE_CONTENTLANGUAGE :
RESOURCE_CREATIONTIME :
RESOURCE_LASTACCESSTIME :
RESOURCE_LASTWRITETIME :
RESOURCE_STREAMSIZE :
RESOURCE_ISCOLLECTION : True
RESOURCE_ISSTRUCTUREDDOCUMENT :
DEFAULT_DOCUMENT : http://hodentek/Default.htm;
http://hodentek/Default.asp;
http://hodentek/index.htm; http://hodentek/iisstart.asp;
RESOURCE_DISPLAYNAME : ASPFree
RESOURCE_ISROOT : False
RESOURCE_ISMARKEDFOROFFLINE :
RESOURCE_METATAGS :
RESOURCE_LISTBASETYPE :
DAV:name : ASPFree
DAV:parentname : http://hodentek/DevHome
DAV:displayname : ASPFree
DAV:iscollection : True
DAV:isroot : False
DAV:defaultdocument : http://hodentek/Default.htm;
http://hodentek/Default.asp;
http://hodentek/index.htm; http://hodentek/iisstart.asp; Test.aspx
Test.bmp
Test.htm
Test.xls --------------------------------------
Next: Copying files from one folder to another >>
More Database Articles
More By Jayaram Krishnaswamy