mickey wrote:
On Thu, 23 Sep 2004 07:22:23 +1000, build <bu*****@datafast.net.au>
you typed some letters in random order:
build wrote:
G'day All,
I have a problem with this loop.
There are a number of .txt files in 'myPath'.
tmpFile = Dir(myPath & "\*.txt")
'PROCESS FOLDER
Do Until tmpFile = ""
<lottsa code>
<too much to post>
tmpFile = Dir
Loop
The first 'tmpFile = Dir(myPath & "\*.txt")'
returns the first .txt file however,
when I get to the 'tmpFile = Dir' it returns
a zero-length string ("").
Can anyone give *any* ideas what, where I should
look in the ensuing code for the problem.
I've been looking for 2 days now and am at a
total loss.
tia
build
G'day All,
OK looks like my question is not clear enough.
What can I be doing in the code between the
'Do Until tmpFile = ""' and the 'tmpFile = Dir'
that would make the second 'Dir' return a zero
length string?
Is that clearer?
tia
build
I use a similar piece of code to delete old log files
Notice the start of the do/while loop it differs from yours
Perhaps that's the problem?
I just tested it again and killed 192 files with this...
<code>
Function Kill_Files(Pad As String, Datum As Date, Patroon As String)
Dim MyFile As String
MyFile = Dir(Pad & "\" & Patroon)
Do While MyFile <> ""
If FileDateTime(Pad & "\" & MyFile) < Datum Then
Kill (Pad & "\" & MyFile)
End If
MyFile = Dir ' Get next entry.
Loop
End Function
</code>
Groetjenz,
Mickey
G'day Mickey,
THANK YOU for your reply.
Do While myFile "is not equal to empty string"
is the same as:
Do Until myFile "is equal to empty string"
What I've done is not an answer but avoids the problem.
Dim fileList() 'array to store filenames
Dim i as Integer 'loop counter
tmpFile = Dir(myPath & "\*.txt") 'get the first file name
Do Until tmpFile = "" ' do until empty string
ReDim Preserve fileList(i) 'set the size of array
fileList(i) = tmpFile 'put da name in array
tmpFile = Dir 'get next filename
i = i + 1 'increment counter
Loop
For i = 0 To UBound(fileList)
tmpFile = fileList(i)
<offending & offensive code>
Next i
actually it's probably clearer, easy to read etc, so better code.
Thank you again Mickey.
build