Dir() function problem
- From: Peter Plumber <Klempner@xxxxxxxxxx>
- Date: Tue, 24 Oct 2006 13:09:51 +0200
hi,
I wanted to traverse a complete directory structure
and search for some files to process
I found that I get "Invalid procedure call or argument" (5)
from sCurEntry = Dir$()
when there is a directory like ".settings"
is this a documented feature?
I am using WindowsXP. Does this happen with other versions too.
What is the supposed workaround?
thanks
Peter
Test Code:
Private Sub readDir(ByVal sInitialDir As String)
Dim sCurEntry As String
Dim sFullPath As String
If Not Right$(sInitialDir, 1) = "\" Then
sInitialDir = sInitialDir & "\"
End If
sCurEntry = Dir$(sInitialDir, vbDirectory)
Do Until Len(sCurEntry) = 0
sFullPath = sInitialDir & sCurEntry
If sCurEntry = "." Or sCurEntry = ".." Then
'
ElseIf CBool(GetAttr(sFullPath) And vbDirectory) Then
readDir sFullPath & "\"
Else
'processFile sCurEntry, sFullPath
End If
sCurEntry = Dir$()
Loop
End Sub
Sub Main()
MkDir "D:\Test\
MkDir "D:\Test\.settings\"
readDir "D:\Test\
End Sub
.
- Follow-Ups:
- Re: Dir() function problem
- From: Ulrich Korndoerfer
- Re: Dir() function problem
- From: Karl E. Peterson
- Re: Dir() function problem
- From: expvb
- Re: Dir() function problem
- From: Tony Proctor
- Re: Dir() function problem
- Prev by Date: Re: Not = versus <>
- Next by Date: Re: How to tell if .NET Framework is installed
- Previous by thread: How to tell if .NET Framework is installed
- Next by thread: Re: Dir() function problem
- Index(es):