Getting File Sizes from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I got the code below from the Access newsgroup. It works fine for filenames
like c:\temp but I need to pass a file name formatted like
\\sec-app-test\images\img1.tif. Any help would be appreciated.

Public Function DirSize&(Optional sDir$, Optional sMask$ = "*.*")
Dim n&, sFile$
If sDir = vbNullString Then
sDir = VBA.CurDir$
End If
'If VBA.Right$(sDir, 1) <> Application.PathSeparator Then
' sDir = sDir & Application.PathSeparator
'End If

sFile = VBA.Dir$(sDir & sMask)
Debug.Print "sFile = ", sFile, "sDir =", sDir
While sFile <> vbNullString
n = n + VBA.FileLen(sDir & sFile)
sFile = VBA.Dir$()
Wend
DirSize = n
End Function
 
The code seems to work fine with UNC paths as it is, what problem are you
experiencing?

Here is the result of my test in the Immediate window ...

? dirsize("\\beech\documents\", "*.*")
sFile = basExpandTime.bas sDir = \\beech\documents\
148802460

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top