ERFORDERLICHE
OBJEKTE
1 Form (frmMain)
4 Listboxes
(lstDateiname, lstOrdnername, lstDateifehler, lstOrdnerfehler)
Eigenschaft Sorted=True
1 Commandbutton (Command1)
FORM-CODE
Public Sub ScanDrive(strStartPath As String, strPattern As String)
Dim strTemp, strRepeat, Dateiname As String
On Error Resume Next
If Right(strStartPath, 1) <> "\" Then _
strStartPath = strStartPath + "\"
strTemp = Dir(strStartPath & strPattern)
If Right(strStartPath, 1) <> "\" Then _
strStartPath = strStartPath + "\"
Do While Len(strTemp)
Dateiname = strStartPath & strTemp
frmMain.Caption = Dateiname
frmMain.lstDateiname.AddItem (Len(Dateiname) & ":" & Dateiname)
DoEvents
strTemp = Dir()
Loop
strTemp = Dir(strStartPath, vbDirectory)
Do While Len(strTemp)
If (strTemp <> ".") And (strTemp <> "..") Then
If (GetAttr(strStartPath & strTemp) And vbDirectory) = _
vbDirectory Then
frmMain.lstOrdnername.AddItem _
(Len(strStartPath & strTemp) & _
":" & strStartPath & strTemp)
ScanDrive strStartPath & strTemp, strPattern
strRepeat = Dir(strStartPath, vbDirectory)
Do While strRepeat <> strTemp
strRepeat = Dir()
Loop
End If
End If
strTemp = Dir()
Loop
On Error GoTo 0
End Sub
Private Sub Command1_Click()
lstDateiname.Clear
lstOrdnername.Clear
lstDateifehler.Clear
lstOrdnerfehler.Clear
Call ScanDrive("c:\test", "*.*")
For x = lstDateiname.ListCount - 1 To 0 Step -1
On Error GoTo err1
lstDateiname.ListIndex = x
tmp = lstDateiname.List(x)
tmp = Mid(tmp, InStr(tmp, ":") + 1, Len(tmp))
Name tmp As LCase(tmp)
err1:
If Err.Number <> 0 Then lstDateifehler.AddItem _
Error(Err.Number) & " bei " & tmp
Next x
For x = lstOrdnername.ListCount - 1 To 0 Step -1
On Error GoTo err2
lstOrdnername.ListIndex = x
tmp = lstOrdnername.List(x)
tmp = Mid(tmp, InStr(tmp, ":") + 1, Len(tmp))
Name tmp As LCase(tmp)
err2:
If Err.Number <> 0 Then lstOrdnerfehler.AddItem _
Error(Err.Number) & " bei " & tmp
Next x
Caption = lstDateiname.ListCount
Me.Caption = "Fertig...!"
End Sub
|