Results 1 to 7 of 7

Thread: Search string in multiple files.

  1. #1

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Search string in multiple files.

    i need to check a text in a lakh of files. as now am looping through files, is there any other fast approach to make it work easily.
    Visual Studio.net 2010
    If this post is useful, rate it


  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: Search string in multiple files.

    are the files all in 1 folder?

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,481

    Re: Search string in multiple files.

    vb Code:
    1. Dim relevantFileNames As ReadOnlyCollection(Of String) = My.Computer.FileSystem.FindInFiles(My.Application.Info.DirectoryPath, ComboBox1.Text, False, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")

    FindInFiles parameters are:
    • directory to search
    • text to find
    • ignore case
    • search options
    • file wildcards

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Search string in multiple files.

    Consider using the windows default file search

    My.Computer.FileSystem.FindInFiles Method

    Edit:Little slow in posting
    Please mark you thread resolved using the Thread Tools as shown

  5. #5

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: Search string in multiple files.

    Quote Originally Posted by .paul. View Post
    are the files all in 1 folder?
    yes.. but having subfolders..

    Thanks,paul & Dana.. i check and come back..
    Visual Studio.net 2010
    If this post is useful, rate it


  6. #6

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: Search string in multiple files.

    Findinfiles looping through all files(Pls refer this..).. its taking much time in directory.getfiles().
    Is there any other API which uses Search using some indexing techniques? i need the data in seconds..
    Visual Studio.net 2010
    If this post is useful, rate it


  7. #7
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Search string in multiple files.

    Quote Originally Posted by vijy View Post
    Findinfiles looping through all files(Pls refer this..).. its taking much time in directory.getfiles().
    Is there any other API which uses Search using some indexing techniques? i need the data in seconds..
    The link says Data base connection Error. Do you want to search only in few file types . If yes the consider using the wild cards

    Code:
    Dim value As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = 
    
    My.Computer.FileSystem.FindInFiles(directory ,containsText ,ignoreCase ,searchType ,"*.txt")

    Read the example here
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width