Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Dir Function

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Dir Function
"Vilem Sova" <vsova[ at ]internode.on.net> 20.09.2006 07:49:24
I've been battling with the Dir function, to try to get a list of all
subdirectories (including lower subdirectories) within a particular
directory - but without much success.

I'm sure I've seen code somewhere that'll do the trick.

Any help would be appreciated.

Thanks
Vilem Sova


Re: Dir Function
Stefan Hoffmann <stefan.hoffmann[ at ]explido.de> 20.09.2006 09:40:00
hi Vilem,

Vilem Sova wrote:
[Quoted Text]
> I've been battling with the Dir function, to try to get a list of all
> subdirectories (including lower subdirectories) within a particular
> directory - but without much success.
> I'm sure I've seen code somewhere that'll do the trick.
Use Dir("Path", vbDirectory). Executing Dir() subsequently will give you
normal files and folders in "Path".


mfG
--> stefan <--

Re: Dir Function
"bob" <rgalway[ at ]optonline.net> 20.09.2006 22:26:34
Try these resources:
http://www.mvps.org/access/modules/mdl0013.htm
http://www.vba-programmer.com/
Bob

"Vilem Sova" <vsova[ at ]internode.on.net> wrote in message
news:e9nJUlI3GHA.4648[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> I've been battling with the Dir function, to try to get a list of all
> subdirectories (including lower subdirectories) within a particular
> directory - but without much success.
>
> I'm sure I've seen code somewhere that'll do the trick.
>
> Any help would be appreciated.
>
> Thanks
> Vilem Sova
>


Re: Dir Function
"Albert D. Kallal" <PleaseNOOOsPAMmkallal[ at ]msn.com> 21.09.2006 06:13:25
Try this code...it will "walk" all sub-dirs for you....


Sub dirTest()

' this code is just to test/show how the sub works...

Dim dlist As New Collection
Dim startDir As String
Dim i As Integer

startDir = "C:\access\"
Call FillDir(startDir, dlist)

MsgBox "there are " & dlist.Count & " in the dir"

' lets printout the stuff into debug window for a test

For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i

End Sub


Sub FillDir(startDir As String, dlist As Collection)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)

Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist)
Next vFolderName

End Sub


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal[ at ]msn.com


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net