clsSearchFilesAL ClassA very powerful class used to search files; supports asynchronous mode and recursion on subdirectories.
|
| Name | Description |
|---|---|
| eSearchFilesWhat | Search flag |
| Name | Description |
|---|---|
| ItemFound | Raised if the [RaiseEvents] is True for every item found during the search |
| Name | Type | Description |
|---|---|---|
| RaiseEvents | (Boolean) | Gets or sets the ability to receive events from this class |
| Name | Type | Description |
|---|---|---|
| CountedFiles | (Long) | Returns the number of files found during the search (in Async mode) |
| CurrentDir | (String) | Returns the current directory when searching (in Async mode) |
| GetFileDate | Returns Datetime info about a specified file | |
| HasBeenStopped | (Boolean) | Returns True if the searching has finished as a result of a StopSearch function |
| IsSearching | (Boolean) | Returns true if the searching process is running (in Async mode) |
| SearchFilePatternPathNoPatternAL | (cArrayList) | Searches for files matching a certain pattern into the passed folder and subfolders; the pattern is only applied on files Returns a cArrayList of [clsSearchFilesFInfo] objects |
| SearchInPathAL | (cArrayList) | Searches in the specified path for every file/folder contained; returns a cArrayList of [clsSearchFilesFInfo] objects |
| SearchPathPatternAL | (cArrayList) | Searches in the specified folder for a certain pattern; the pattern is applied to files and folders Returns a cArrayList of [clsSearchFilesFInfo] objects |
| SortResultsAL | Sort the resulting ArrayList ascending or descending | |
| StopSearch | Stops the search (in Async mode) |
Dim osf As clsSearchFiles
Set osf = New clsSearchFiles
Dim oc As Collection
Set oc=osf.SearchInPath(...)Dim osfi As clsSearchFilesFInfo
For i = 1 To oc.Count
Set osfi = oc.Item(i)
'Use the osfi class here ;-)
Next
Option Explicit
'Uses events
Private WithEvents moSearchSF As clsSearchFilesAL
Private Sub Form_Click()
Dim osfi As clsSearchFilesFInfoAL
Dim ar As cArrayList
Dim sPattern As String
sPattern = "*.*"
Dim i As Long
Dim s As String
'Search files
Set ar = moSearchSF.SearchFilePatternPathNoPatternAL("c:\*.*", esfw_only_files, True, True)
'Sort results Ascending
moSearchSF.SortResultsAL ar, True
'
'Manage results
'
MsgBox "Passed from " & moSearchSF.CountedFiles & " files..."
End Sub
Private Sub Form_Load()
Set moSearchSF = New clsSearchFilesAL
moSearchSF.RaiseEvents = True
MsgBox "Click on the form to start the search, close the form to Stop"
End Sub
Private Sub Form_Unload(Cancel As Integer)
If moSearchSF.IsSearching() Then
moSearchSF.StopSearch
Cancel = 1
MsgBox "The search has been stopped"
End If
End Sub
Private Sub moSearchSF_ItemFound(osfi As clsSearchFilesFInfoAL)
ctlUniLabelXP1.Caption = "Searching on: " & moSearchSF.CurrentDir
End Sub