Logo
English Russian German French Spanish Italian
contact usprivacy
   Support Forums
chart
• Adjust flexgrid cell
• Animation
• Centering form text
• Coffee machine
• Creating fileshares
• Creating shortcuts
• Custom buttons
• Directory browser
• Disable mouse events
• File search by ext
• File transfer
• File watcher
• Formatting flexgrid
• Get Content Type
• Get HTML source
• Get modem port
• HTTP proxy
• ipconfig
• Large file split/merge
• MAPI
• MCI Sound Player
• Menu with images
• MP3 normalizer
• Net Send
• Netstat 2000
• No duplicate entries
• Outlook Address Book
• Set font color
• Shapes
• SOAP test
• Text-to-image
• Text file viewer
• Text find/replace
• UPS component
• View NT groups
• Word template
• Writing DNS control
    • Using DNS control
• Writing SMTP control
    • Sending email
    • Mailing list
• Writing WhoIs control
    • Using WhoIs control
• View HTML source
OISV - Organization of Independent Software Vendors - Contributing Member
VB projects - Recursive file search by extension

Description: recursively search selected directory and all its sub-directories for files with specified extension
Minimum requirements: VB6
Download: source code
Screenshot:
VB projects - Recursive file search by extension
Project: EXE
Controls: DriveListBox Drive1, TextBox txtExt, CommandButton cmdGet (Caption = "Get"), TextBox txtOut (MultiLine = -1 'True, ScrollBars = 3 'Both), Label Label1 (Caption = "Extension: ")
Additional references: Microsoft Scripting Runtime
Code:
Option Explicit

Dim fso As New FileSystemObject
Dim fld As Folder

Private Sub cmdGet_Click() Me.MousePointer = vbHourglass cmdGet.Enabled = False txtExt.Enabled = False txtOut = "" FindFile Dir1.Path, txtExt txtOut = txtOut & vbCrLf & "Search complete" txtOut.SelStart = Len(txtOut) cmdGet.Enabled = True txtExt.Enabled = True Me.MousePointer = vbDefault End Sub
Private Function FindFile(ByVal sFol As String, sFile As String) As Long Dim tFld As Folder, tFil As File, FileName As String Set fld = fso.GetFolder(sFol) For Each tFil In fld.Files If Mid(tFil.Name, InStrRev(tFil.Name, ".") + 1) = txtExt Then _ txtOut = txtOut & fso.BuildPath(fld.Path, tFil.Name) & vbCrLf txtOut.SelStart = Len(txtOut) DoEvents Next If fld.SubFolders.Count > 0 Then For Each tFld In fld.SubFolders DoEvents FindFile = FindFile + FindFile(tFld.Path, sFile) Next End If End Function
Private Sub Drive1_Change() Dim sDir As String sDir = Drive1.Drive If InStr(sDir, "\\") <> 0 Then sDir = Trim(Mid(sDir, InStr(sDir, "\\"))) If InStr(sDir, "]") <> 0 Then sDir = Left(sDir, InStr(sDir, "]") - 1) ElseIf InStr(sDir, "[") <> 0 Then sDir = Trim(Left(sDir, InStr(sDir, "[") - 1)) End If If Right(sDir, 1) <> "\" Then sDir = sDir & "\" Dir1.Path = sDir End Sub
Private Sub Form_Load() Drive1_Change End Sub
Private Sub Form_Unload(Cancel As Integer) End End Sub

Copyright © 1996-2010 OstroSoft. All rights reserved. info@ostrosoft.com