ha!! i did it!!

the following is a major revision of my origional DIRPLUS() udf.... this only reutrns files/folders, and does not give you the option of filtering on using file extension (i will add this feature once i have a full replacement for the original UDF)

This also returns the FSO object of folders/files as a defalut return.

Code:

function DirPlus($path,optional $sfflag)
dim $fso, $f, $tf, $folder, $file, $i, $temp, $item
dim $tarray[0]
$fso = CreateObject("Scripting.FileSystemObject")
$f = $fso.getfolder($path)
for each $folder in $f.subfolders
$tarray[$i] = $folder
$i = $i + 1
redim preserve $tarray[$i]
if $sfflag
$temp = dirplus($folder, $sfflag)
for each $item in $temp
$tarray[$i] = $item
$i = $i + 1
redim preserve $tarray[$i]
next
endif
next
for each $file in $f.files
$tarray[$i] = $file
$i = $i + 1
redim preserve $tarray[$i]
next

if $i
redim preserve $tarray[$i-1]
else
$tarray = 0
endif
$dirplus = $tarray
endfunction




an example....

Code:

$dir = dirplus("c:\program files",1) ;return all subfolder information

;Using the FSO to return information
for each $file in $dir
if $file.type <> "file folder"
? "file name = " $file.name
? "File type = " $file.type
? "FIle size = " $file.size
endif
next



Bryce


Edited by Bryce (2004-09-11 11:37 PM)