Гуру программирования - оптимизируйте плиз!
без рекурсии получение всех поддиректорий и файлов
без рекурсии получение всех поддиректорий и файлов
Код:
Function GetSubFile (hom As Variant)
Dim h,d,s As String
Dim p() As Variant
Redim Preserve p(0)
Dim k As Variant
k=0
If Right(hom,1)<>"\" Then hom=hom+"\"
h=hom+";"
On Error Goto errdir
Do While Instr(1,h,";")>0
d=Left(h,Instr(1,h,";")-1)
h=Mid(h,Instr(1,h,";")+1)
s=Dir(d+"*.*",16)
Do While s<>""
If s<>"." And s<>".." And 16=Getfileattr ( d+s ) Then
h=d+s+"\;"+h
Else
If s<>"." And s<>".." And 16<>Getfileattr ( d+s ) And 8<>Getfileattr ( d+s ) Then
Redim Preserve p(k)
p(k)=d+s
k=k+1
End If
End If
s=Dir()
Loop
Loop
GetSubFile=p
Exit Function
errdir:
GetSubFile=""
Exit Function
End Function