ID: 334
Viewed: 3661
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
Recursive File Search
Highlight all by clicking in box
<!---Declaration--->
Option Explicit
Private sLog As String
Highlight All
<!---Code--->
Private Sub LogFilesOfType(ByVal sType As String, Optional ByVal sInitDir As String = "C:")
Dim sSubFolder() As String
Dim iSubFolder As Long
Dim sDir As String
Dim bLogged As Boolean
On Error Resume Next
If Right$(sType, 1) <> "," Then sType = sType & ","
If Right$(sInitDir, 1) <> "" Then sInitDir = sInitDir & ""
sDir = Dir(sInitDir & "*", vbArchive + vbHidden + vbNormal + vbReadOnly + vbSystem + vbDirectory)
While Len(sDir)
If (GetAttr(sInitDir & sDir) And vbDirectory) = vbDirectory Then
If Left(sDir, 1) <> "." Then
ReDim Preserve sSubFolder(iSubFolder)
sSubFolder(iSubFolder) = sDir
iSubFolder = iSubFolder + 1
End If
ElseIf InStr(sDir, ".") Then
If InStr(sType, Mid$(sDir, InStr(sDir, ".")) & ",") Then
If Not bLogged Then
' sLog = sLog & vbCrLf & sInitDir & vbCrLf
bLogged = True
End If
List1.AddItem sInitDir & sDir
'sLog = sLog & " " & Left$(sDir & Space(50), 50) & Chr(9) & Format(FileDateTime(sInitDir & sDir), "HH:MM:SS AM/PM MM/DD/YYYY") & Chr(9) & FileLen(sInitDir & sDir) & vbCrLf
Caption = "Logged: " & Val(Mid$(Caption, 9)) + 1
End If
End If
sDir = Dir
Wend
If iSubFolder Then
For iSubFolder = 0 To UBound(sSubFolder)
Call LogFilesOfType(sType, sInitDir & sSubFolder(iSubFolder))
Next
End If
End Sub
Private Sub Command1_Click()
sLog = ""
Call LogFilesOfType(".txt,.scr")
Open "C:Log.txt" For Output As 1
Print #1, sLog
Close 1
Shell "notepad.exe C:log.txt", vbNormalFocus
End Sub;
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.