Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
Information Mgmt
New to Lotus
How to buy
Live demos
Technical library
Forums & community
Java™ technology
Open source
SOA and Web services
Web development
My developerWorks
About dW
Submit content

developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum



PreviousPrevious NextNext

...and another...
Mark Taylor 30.Nov.18 03:00 PM a Web browser
Notes Client All Releases All Platforms

You don't mention - are you looking for a specific file in a specific location? Or do you have to search the entire drive for a specific file?


A solution to get directories and files in LotusScript
Posted by Sultan Yakalelo on 31.Jan.01 at 02:11 PM using a Web browser
Category: Domino Designer -- LotusScriptRelease: All ReleasesPlatform: Windows NT

Below is one solution to get all directories and files from a specified location, something many developers seem to struggle around (see technote #172128, in which the workaround Lotus gave was not satisfying either because I was still getting the "Illegal function call" error).

More specifically, the function gets files and directories from one location and copies them into another location by using arrays and recursion. Hence, be careful, whereever there is recursion, there might be possible memory problems if too many recursive calls are made.

It saves all the content of a directory into an array and then loops through that array.
If it finds a directory when looping through the array, the function recursively calls itself (with the new parameters including the directory found);
Else copies the files into the appropriate directory.

Any comments/suggestions/questions/remarks welcome!

Sub gCopyMultipleFiles(Byval vstrFromPath As String, Byval vstrToPath As String)
Dim astrFileList() As String
Dim strDirOrFile As String
Dim intCount As Integer, i As Integer

strDirOrFile$ = Dir$(vstrFromPath & "\", ATTR_DIRECTORY)
While (strDirOrFile$ <> "")
If Not(strDirOrFile$ = "." Or strDirOrFile$ = "..") Then ' Do not save . and .. directories (current and parent directories)
Redim Preserve astrFileList(intCount)
astrFileList(intCount) = strDirOrFile$
intCount = intCount + 1
End If

If Not(gintDirectoryExists(vstrToPath & "\")) Then ' If it is a new directory, create it
Mkdir vstrToPath
End If

For i = 0 To intCount-1
strDirOrFile$ = astrFileList(i)
If gintDirectoryExists(vstrFromPath & "\" & strDirOrFile$ & "\") Then
' We have a sub-directory, go into that sub-directory by calling gCopyMultipleFiles with parameters including the new directory
gCopyMultipleFiles vstrFromPath & "\" & strDirOrFile$, vstrToPath & "\" & strDirOrFile$
' We have a file, copy it into current directory
gCopyFile vstrFromPath & "\" & strDirOrFile$, vstrToPath & "\" & strDirOrFile$, True
End If
End Sub

Sub gCopyFile(Byval vstrFromFilePath As String, Byval vstrToFilePath As String)
' Copies a file from one location to the other. For additional security, you can check if the source file exists
' at the source and destination, if you can overwrite it etc.
On Error Resume Next
Filecopy vstrFromFilePath, vstrToFilePath ' Copy the source to the destination, the calling routine should handle error
If Err Then
Error Err, strErrorPrefix & Cstr(Error)
Exit Sub
End If
On Error Goto 0
End Sub

Public Function gintDirectoryExists(Byval vstrDirectoryPath) As Integer
' Checks whether a directory exists, returns true or false
Dim strDirectoryFound As String


On Error Resume Next
strDirectoryFound = Dir$(vstrDirectoryPath, ATTR_DIRECTORY)
If Err Then
Exit Function
End If
On Error Goto 0

If strDirectoryFound <> "" Then
End If
End Function

agent that finds file on the users ... (Baba Tony 30.Nov.18)
. . RE: agent that finds file on the us... (Mark Taylor 30.Nov.18)
. . Here's another (Mark Taylor 30.Nov.18)
. . ...and another... (Mark Taylor 30.Nov.18)

Document Options

  Document options
Print this pagePrint this page

Search this forum

Forum views and search

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Advanced search

Member Tools

RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds


Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds


IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums

 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite