API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Getting Windows "My Documents" Directory
This quick tip can be used to read the "My Documents" (or "Documents") directory on a Windows machine.

Function GetMyDocsSubdir() As String
   On Error GoTo BubbleError
   ' Get the user's "My Documents" subdirectory name.
   Dim directory As String
   Dim dirName As String
   
   directory = Environ$("USERPROFILE")
   If Right(directory, 1) <> "\" Then directory = directory & "\"
   dirName = Dir$(directory & "*.*", 16)
   Do While dirName <> ""
       If LCase(dirName) = "documents" Or LCase(dirName) = "my documents"  Then
           GetMyDocsSubdir = directory & dirName & "\"
           Exit Function  ' ================================================================
       End If
       dirName = Dir$()
   Loop
   
   ' Couldn't find "My Documents" or "Docuemnts". Return the user's main profile subdirectory
   GetMyDocsSubdir = directory
 
   Exit Function
BubbleError:
   Error Err, Error$ & Chr$(10) & "in function " & GetThreadInfo(1) & ", line " & CStr(Erl)
End Function