Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Something like 'Filer'
Message
From
11/12/2000 11:25:16
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00450922
Message ID:
00451618
Views:
21
>In another thread, I was searching for a way to use the Windows Explorer "search" programatically. This lead to a discussion of available search products, which led me to "Filer". I checked it out and it's just what I need. Or was, until someone mentioned that it's not distributable. Sigh.
>
>So is there anything like it that _is_ distributable? What about my original question of using the built-in search? No one actually answered that.
>
>Thanks,
>
>Michelle

Here's some code to get you started using the the FileSystemObject
*-----------------
* FileList.prg
* Parameters:
*     tcSearch:      Required. The string to search for
*     tcStartDir: Optional. The directory to start in. Defaults to current directory
*     tlText:      Optional. If .F. (default) find file names containing tcSearch
*                    If .T. find file contents containing tcSearch
* Example: 
*     FileList("vfp", Home())
*     to find all files in the Home() directory
*     containing "vfp"
*-----------------

LParameters tcSearch, tcStartDir, tlText
Local lcSearch, loFolder, loFSO
Store "" To lcSearch

If Empty(tcSearch) Or Vartype(tcSearch)#"C"
     MessageBox("Search string is required.", 48, "FileList")
     Return
EndIf

lcSearch = Lower(tcSearch)
loFSO = CreateObject("Scripting.FileSystemObject")

If Empty(tcStartDir) Or Vartype(tcStartDir)#"C"
     tcStartDir = FullPath(CurDir())
EndIf

loFolder = loFSO.GetFolder(tcStartDir)
ListX(loFolder, tcSearch, tlText)

If Used("cuFindLog")
     Select cuFindLog
     Go Top
     Browse Last Nowait
EndIf

************ End of Program ************
*----------
* ListX
*----------
Function ListX(toFolder, tcSearch, tlText)
     Local lcSearch, loFile, loFolder, loSub
     Store "" To lcSearch
     Local lcSearch
     lcSearch = Lower(tcSearch)

     lcMsg = "Searching " + toFolder.Path
     Wait Window lcMsg Nowait

     *--     loop through files in the given folder
     For Each loFile In toFolder.Files
          Wait Window lcMsg + Chr(13) + loFile.Name Nowait
          If tlText
               If lcSearch $ Lower(FileToStr(loFile.Path))
                    LogFile(loFile)
               EndIf
          Else
               If lcSearch $ Lower(loFile.Name)
                    LogFile(loFile)
               EndIf
          EndIf
     EndFor

     *--     loop through subfolders, if any
     If toFolder.SubFolders.Count > 0
          For Each loSub In toFolder.SubFolders
               ListX(loSub, tcSearch, tlText)
          EndFor
     EndIf

EndFunc

*------------
* LogFile
*------------
Function LogFile(toFile)
     If !Used("cuFindLog")
          Create Cursor cuFindLog (cfile c(100))
     EndIf
     Insert Into cuFindLog Values (toFile.Path)
EndFunc
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform