Q

How can I get a list of folders available on the server?

Two questions:

  1. How can I get a list of folders available on the server?

  2. If I want to access a list of databases in a particular folder, can I/how do I get a handle on only these databases if I know the folder name?

You can get a list of all the folders in a particular directory of the server using the Dir$ function in LotusScript. However, this code would have to run on the server –- not from a workstation. And the server agent must run with unrestricted access. You can run a server agent from the workstation using the NotesAgent.RunOnServer method. This article shows how to do that.

Dir$ can also locate all the .nsf files in a folder. But, Notes provides another way to do that, the NotesDBDirectory class. There's no way to tell the class to restrict itself to databases in a specific folder. But, it's very fast if all you do is look at the database filepaths. You don't have to "Open" the NotesDatabase object to read the Filepath property. So you can very quickly iterate through all the databases and skip the ones that don't start with the right path. Other advantages of NotesDbDirectory are: it will work in code run from a workstation and does not require unrestricted access.

Function AllDBsInFolder(Byval 
strServer As String, Byval 
strFolder As String, 
Byval intFileType As Integer) As Variant 
        On Error Goto oops 
        Redim result(0 To 100) As 
NotesDatabase 
        Dim intCount As Integer 
        Dim dbdir As New 
NotesDbDirectory(strServer) 
        Dim db As NotesDatabase 
        
        If Right$(strFolder, 1) <> 
"" Then strFolder = strFolder & "" 
        Set db = dbdir.
GetFirstDatabase(intFileType) 
        Do Until db Is Nothing 
                If Left$(db.FilePath , 
Len(strFolder)) = strFolder Then 
                        If intCount > 
Ubound(result) Then 
                                Redim 
Preserve result(0 To intCount + 100) 
                        End If 
                        Set result(intCount) = db 
                        intCount = intCount + 1 
                End If 
                Set db = 
dbdir.GetNextDatabase( ) 
        Loop 
        If intCount > 0 Then 
                If intCount >= 
Ubound(result) Then 
                        Redim Preserve 
result(0 To intCount - 1) 
                End If 
                AllDBsInFolder = result 
        End If 
        Exit Function 
oops: 
        Error Err , Error & 
"//AllDBsInFolder:" & Erl 
End Function 

. . . 
Dim matches As Variant 
matches = AllDBsInFolder
("Rex/Yoyodyne", "mail", DATABASE) 
If Not IsEmpty(matches) Then 
        Forall db In matches 
                ' process one database here. 

Do you have comments on this Ask the Expert question and response? Let us know.

This was first published in October 2004

Dig deeper on LotusScript

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close