for lyy = 1 to 10
? "Round " + transform(lyy)
t1=seconds()
for lxx = 1 to 20
oFS = createobject("scripting.FileSystemObject")
oFolder = oFS.GetFolder("d:\winnt\system32\")
With oFolder
n = .Files.Count + .Subfolders.Count
Endwith
oFolder = .NULL.
oFS = .NULL.
endfor
t2 = seconds() - t1
? n
*local array lafiles[1]
t3 = seconds()
for lxx = 1 to 20
n = adir(lafiles,"d:\winnt\system32\*.*","DHS") - 2
* release lafiles
endfor
t4 = seconds() - t3
?n
? transform(t2),transform(t4)
endfor
If you uncomment the 'release lafiles' to perform cleanup after each pass, then FSO becomes over 4x faster.
Since we were dealing with counts only, IMO FSO would be the way to go. There is no added overhead in building an array just to get the number of files in a directory. If we wanted to perform some other task (e.g. populating a control with file names) then FSO probably would not be the way to go because of the overhead of COM.
In this instance, the overhead of an array far outweighs the overhead of COM.Larry Miller
MCSD
LWMiller3@verizon.net
Accumulate learning by study, understand what you learn by questioning. -- Mingjiao