Searching all text files in a directory

Discussion in 'Questions (Windows Mobile)' started by tsteward, Aug 16, 2008.

  1. tsteward

    tsteward Active Member Licensed User

    Any ideas how I might quickly search all text files (with the extension 'txt') in a single folder for given text?
     
  2. Cableguy

    Cableguy Expert Licensed User

    List all files is easy, searching for a particular string in any of those files...
    The easiest way is to load esch file and do the search in each of them, populating some sort of "Hit-list" with the results...
    But that would be very time and resouce consuming..
     
  3. tsteward

    tsteward Active Member Licensed User

    Yeah well that is what I have done so far.
    I guess I was hoping someone had some other method.

    My Code(obviously I will replace the message box with populating a list)
    Code:
    ALFiles.Clear
      FileSearch(ALFiles,SubString(wikiDir,
    0,StrLength(wikiDir)-1),"*.txt")
      
    For f=0 To ALFiles.Count-1
       FileOpen (c1, ALFiles.Item(f), cRead ,, cASCII)
       contents = FileReadToEnd(c1)
       FileClose (c1)
       r=StrIndexOf(contents,
    "[" & currentpage & "]",0'+ StrIndexOf(contents,"][" & currentpage & "]]",0)
       s = StrIndexOf(contents, "][" & currentpage & "]",0)
       
    If r>-1 AND s = -1 Then
        
    Msgbox(ALFiles.Item(f) & crlf & "Is Backlink")
       
    End If
      
    Next
     
  4. tsteward

    tsteward Active Member Licensed User

    Search Subdirectories

    How can I get all the *.txt files in the current directory and ALL sub directories. Not sure how to find and keep track of all the sub dirs
     
  5. klaus

    klaus Expert Licensed User

    Here you have an example, it goes only 3 levels of subdirectories deep, if you need more you can add the needed code.

    Best regards.
     

    Attached Files:

  6. specci48

    specci48 Well-Known Member Licensed User

    Just to complete this thread: The solution is here.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice