View Files in a Directory
Does anyone know the best way to get a list of files in a directory?
Currently I am using the following, but am getting an error occasionally...
strDirPath = GetUserSetting("Import_Folder")
If Right$(strDirPath, 1) <> "\" Then
strDirPath = strDirPath & "\"
End If
If GetAttr(strDirPath) = vbDirectory Then
strFileName = Dir(strDirPath, vbDirectory)
Do Until Len(strFileName) = 0
' Exclude ".", "..".
If (strFileName <> ".") And (strFileName <> "..") Then
' Make sure we do not have a sub-directory name.
If (GetAttr(strDirPath & strFileName) _
And vbDirectory) <> vbDirectory Then
Set rs = New ADODB.Recordset
strSQL = "SELECT file_PK FROM D_Files WHERE file_FilePath = '" & strDirPath & strFileName & "'"
rs.Open strSQL, cn
If rs.BOF And rs.EOF Then
LoadFile (strDirPath & strFileName)
End If
End If
End If
strFileName = Dir()
Loop
End If
I got it from the Microsoft Site - in case anyone is wondering.
Thanks
Mike
EchoVue.com
__________________
Mike
EchoVue.com
|