Help - searching for multiple files (using wildcard)

mr_operations
mr_operations used Ask the Experts™
on
Hi

I was wondering if any1 could help me or point me to where I could find some info on how to search for files/patterns.

what I want to do is search for all .tmp files, and then delete them.

I was wondering if there is any easy way to do this in VB
without using recursion. Is there any special method where I can use *.tmp 2 ??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Project manager
Commented:
There are several approaches you can use:

First one: just open the search screen from windows

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10

Private Sub Form_Load()
    Dim strPathToSearch As String
    strPathToSearch = "C:\"
    Call ShellExecute(Me.hwnd, "find", strPathToSearch, vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub


Second approach:
use a recursive function to search all the files in a directory. If you get the filename, just check with right(filename,3) = "tmp" then ... to see if it is a tmp-file

Author of the Year 2009

Commented:
Hi mr_operations,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Dhaest's comment(s) as an answer.

mr_operations, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.
==========
DanRollins -- EE database cleanup volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial