Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Document list of a folder

Status
Not open for further replies.

Jerrie85

IS-IT--Management
Feb 10, 2004
29
CA
How would i get the list of documents present in a folder, and iterate through each one of their names?

this in VB;

I can start a session, Get into enterprise, get into personal, using LL_AccessPersonalWorkspace, LL_AccessEnterpriseWS

however, i didn't see a function that lets u access a specific folder with a object ID..;
any help?
 
I used to use ListObjects to retrieve child objects but it was way too slow. I now establish a direct database connection. Samples of each here ....

ListObjects method:

Code:
Function GetNodeIDOld(ByVal lngParent As Long, ByVal strChild As String) As Long
    'returns the node ID of a child of lngParent called strChild
    Dim tmpRecs As Long
    Dim tmpRecord As Long
    Dim lngIndex As Long
    Dim lngID As Long
    Dim strName As String * 2048
    
    Const lngLength As Long = 2048
    Dim lngSize As Long
    On Error GoTo GetNodeIDErr:
    status = LL_ValueAlloc(tmpRecs)
    status = LL_ValueAlloc(tmpRecord)
    status = LL_ListObjects(lngSession, lngVolumeID, lngParent, vbNullString, vbNullString, 0, tmpRecs)
    lngID = 0
    lngIndex = 0
    status = LL_TableGetRecord(tmpRecs, lngIndex, tmpRecord)
    Do
        status = LL_RecordGetString(tmpRecord, "NAME", strName, lngLength, lngSize)
        If UCase$(Left$(strName, lngSize)) = UCase$(Trim$(strChild)) Then
            status = LL_RecordGetInteger(tmpRecord, "ID", lngID)
            Exit Do
        End If
        lngIndex = lngIndex + 1
        status = LL_TableGetRecord(tmpRecs, lngIndex, tmpRecord)
    Loop Until status <> LL_OK
    status = LL_ValueFree(tmpRecs)
    status = LL_ValueFree(tmpRecord)
    GetNodeIDOld = lngID
    DoEvents
GetNodeIDExit:
    Exit Function
GetNodeIDErr:
    Resume GetNodeIDExit
End Function

Database method (objLLConn must already be established, safeSQLString sorts out quotes and stuff):

Code:
Function GetNodeID(ByVal lngParent As Long, ByVal strChild As String) As Long
    'returns the node ID of a child of lngParent called strChild
    'This function gets the ID direct from the database. It is much quicker than looping through the
    'child nodes via LAPI.
    Dim lngID As Long
    Dim strSQLStatement As String
    Dim rsParentNode As ADODB.Recordset
    
    strChild = SafeSQLString(strChild)
    strSQLStatement = "SELECT dataid FROM dtree WHERE name = '" & strChild & "' AND parentid = " & lngParent
    Set rsSiteSynch = objLLConn.Execute(strSQLStatement)
    If rsSiteSynch.EOF Then
        GetNodeID = 0
    Else
        GetNodeID = rsSiteSynch!dataid
    End If
End Function
 
Now I've looked into this, I can see I should have passed a SQL string to the ListObjects function to save looping over the table. Ah well ....

Does anyone have any sample VB.NET code for ListObjects?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top