Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Fastest approach to search text in multiple files

Avatar of Manoj Kumbhar
Manoj Kumbhar asked on
Microsoft ExcelVisual Basic.NETGoogle
6 Comments1 Solution177 ViewsLast Modified:
I need to search a string or text in around 2000 files. Input string is coming from an excel document.

Basically I need to search if UserName exists in 2000 excel files placed at shared location. there are around 3000 users for which I need perform this search. I have developed below code by searching on google but it is taking 3 mins for each user which is too long. Please suggest better way.
Public Shared Function Search(ByVal SearchText As String, ByVal FolderPath As String) As List(Of String)

        Dim searchresult As List(Of String) = New List(Of String)
        Dim list As ObjectModel.ReadOnlyCollection(Of String)

        list = My.Computer.FileSystem.FindInFiles(FolderPath, SearchText, True, FileIO.SearchOption.SearchTopLevelOnly)

        searchresult = list.Select(Function(a) a).ToList()
        'For Each name In list
        '    searchresult.Add(name)
        'Next

        Return searchresult
End Function
ASKER CERTIFIED SOLUTION
Avatar of Ark
ArkFlag of Russian Federation image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers