A
Aaron
I am trying to get a listing of all files in folders and sub folders of
network folders named by Macs. It seems that dir() is tripped up by this.
It gets an error "bad file name or number". Any suggestions on how to fix
this? Here is a bit of my code:
Public Function FindFile(ByVal sfol As String, sfile As String, nDirs As
Integer _
, nfiles As Integer, rs As Recordset) As Long
Dim FileName As String
Dim tfld As Folder
Set fld = fso.GetFolder(sfol)
FileName = Dir(Trim(fso.BuildPath(fld.Path, sfile)), _
vbNormal Or vbSystem Or vbReadOnly) ' *Error on
this line
While Len(FileName) <> 0
FindFile = FindFile + FileLen(fso.BuildPath(fld.Path, FileName))
rs.AddNew
rs.Fields("FileSize") = FileLen(fso.BuildPath(fld.Path, FileName))
rs.Fields("File") = FileName
rs.Fields("Path") = fld.Path
rs.Fields("FileType") = GetAttr(fso.BuildPath(fld.Path, FileName))
rs.Fields("DateMod") = FileDateTime(fso.BuildPath(fld.Path,
FileName))
rs.Update
nfiles = nfiles + 1
Wend
Label1.Caption = "Searching " & vbCrLf & fld.Path & "..."
nDirs = nDirs + 1
If fld.SubFolders.Count > 0 Then
For Each tfld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tfld.Path, sfile, nDirs, nfiles)
Next
End If
End Function
Thanks in advance for your help!
AW
network folders named by Macs. It seems that dir() is tripped up by this.
It gets an error "bad file name or number". Any suggestions on how to fix
this? Here is a bit of my code:
Public Function FindFile(ByVal sfol As String, sfile As String, nDirs As
Integer _
, nfiles As Integer, rs As Recordset) As Long
Dim FileName As String
Dim tfld As Folder
Set fld = fso.GetFolder(sfol)
FileName = Dir(Trim(fso.BuildPath(fld.Path, sfile)), _
vbNormal Or vbSystem Or vbReadOnly) ' *Error on
this line
While Len(FileName) <> 0
FindFile = FindFile + FileLen(fso.BuildPath(fld.Path, FileName))
rs.AddNew
rs.Fields("FileSize") = FileLen(fso.BuildPath(fld.Path, FileName))
rs.Fields("File") = FileName
rs.Fields("Path") = fld.Path
rs.Fields("FileType") = GetAttr(fso.BuildPath(fld.Path, FileName))
rs.Fields("DateMod") = FileDateTime(fso.BuildPath(fld.Path,
FileName))
rs.Update
nfiles = nfiles + 1
Wend
Label1.Caption = "Searching " & vbCrLf & fld.Path & "..."
nDirs = nDirs + 1
If fld.SubFolders.Count > 0 Then
For Each tfld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tfld.Path, sfile, nDirs, nfiles)
Next
End If
End Function
Thanks in advance for your help!
AW