Dir() in Mac directories

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
 
A

Aaron

OK, I got it working now by using "fld.shortpath" as opposed to fld.path.
However now I get an overflow error "6" at the marked line below. Any
suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top