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.
Printable View
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.
are the files all in 1 folder?
vb Code:
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
Consider using the windows default file search
My.Computer.FileSystem.FindInFiles Method
Edit:Little slow in posting :)
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