HELP PLS!!!
Hi, I use UDF Dirplus()
this work fine when use in 1 drive ex c: but when I need use in many drives like c:, d:, e: return a error
Code work fine:
Code:
$origen="c:\"
$FileExt=".doc;.xls;.ppt;.zip;.nsf"
$FullList=DirPlus($origen,$FileExt,1)
For Each $el In $FullList
?$el
Next
Code error:
Code:
$origen="c:\","d:\"
For Each $dr In $origen
$FileExt=".doc;.xls;.ppt;.zip;.nsf"
$fulllist=DirPlus($dr,$FileExt,1)
Next
this is the udf
Code:
Function DirPlus($Dir,$mask,optional $subfolders, optional $datatype)
Dim $file, $subflag, $i, $ii,$pattern
If VarType($_temparray) = 0
Global $_temparray[30], $_i
$_i = 0
Else
$subflag = 1
EndIf
If $Dir = 0 Exit(1) EndIf
If SubStr($Dir,Len($Dir),1) = "\"
$Dir = SubStr($Dir,1,Len($Dir)-1)
EndIf
If $mask = 0
$mask = "*.*"
EndIf
$mask = Split($mask,";")
If Exist($Dir) = 0 Exit(2) EndIf
$file = Dir($Dir + "\*.*")
While @error = 0 AND $file
Select
Case $file = "." OR $file = ".."
;bit bucket!
Case GetFileAttr($Dir + "\" + $file) & 16
$_temparray[$_i] = $Dir + "\" + $file
$_i = $_i + 1
If $subfolders = 1
dirplus($Dir + "\" + $file,"*.*",$subfolders)
If @error <> 0 Exit(1) EndIf
EndIf
Case 1
$_temparray[$_i] = $Dir + "\" + $file
$_i = $_i + 1
EndSelect
If Ubound($_temparray) = $_i
ReDim preserve $_temparray[$_i + 30]
EndIf
$file = Dir("")
Loop
If $subflag = 1
;
Else
ReDim preserve $_temparray[$_i-1]
$dirplus = $_temparray
Select
Case $mask[0] = "*.*"
;return all files!
Case 1
Dim $temparray[Ubound($dirplus)]
$ii = 0
For Each $pattern In $mask
$i = 0
For Each $file In $dirplus
If InStr($file,$pattern)
$temparray[$ii] = $dirplus[$i]
$ii = $ii + 1
EndIf
$i = $i + 1
Next
Next
If $ii > 0
ReDim preserve $temparray[$ii-1]
$dirplus = $temparray
Else
$dirplus = 0
EndIf
EndSelect
Select
Case $datatype = 0
;return filename!
Case $datatype = 1
;return File object handle
$i = 0
$fso = CreateObject("scripting.filesystemobject")
If @error <> 0 AND VarType($fso) <> 9 Exit(@errro) EndIf
For Each $file In $dirplus
If GetFileAttr($file) & 16
$file = $fso.getfolder($file)
Else
$file = $fso.getfile($file)
EndIf
$dirplus[$i] = $file
$i = $i + 1
Next
EndSelect
$_i = 0
$_temparray = 0
Exit(0)
EndIf
EndFunction