Lotus Script - Check if a file or folder exists
Daniel Nashed – 13 December 2024 11:23:34
There isn't a direct function in Lotus Script to check if files exist.
Most of us have written a function like this multiple times as a helper.
I am working on an application which will be available as open source soon and I needed one again...
Here is a version of a check function, which should cover all cases and might be useful for you too.
It doesn't handle hidden files -- I know. But I didn't want to add that logic.
-- Daniel
Function FileFolderExists (FileName As String) As Long
'Returns
' 2 = Directory exists
' 1 = File exists
' 0 = File/Directory does not exist
' -1 = Directory for file does not exist
' -2 = Other error
Dim result As String
FileFolderExists = -2
On Error GoTo ErrorHandler
result = Dir$(FileName, 16)
If (result = "") Then
FileFolderExists = 0
Exit Function
End If
result = Dir$(FileName, 0)
If (result = "") Then
FileFolderExists = 2
Else
FileFolderExists = 1
End If
Exit Function
ErrorHandler:
If (76 = Err) Then
FileFolderExists = -1
End If
Exit Function
End Function
- Comments [1]